# Criterion 2020 Round 4

## Schedule

The contest will start on 2020-03-13T09:00:00Z and will run for 2 hours 30 minutes.

I’m from Chittagong Bangladesh.Can I join this contest?
Where is it situated?

Yes, this is an online open-for-all contest.

1 Like

How to join?
Plz give me suggestions

You can just click on the sign-up button on the contest page and come back when the contest starts.

1 Like

Can I give the contest using my mobile phone?

Helo hjr can u tell me?

Toph works on mobiles with modern web browsers. Depending on what mobile phone you are using, your experience can vary.

Thnx thnx thnx thnx thnx thnx thnx thnx
Ok I will join

1 Like

Can somebody share their code for the first and second problem.

Problem A:
Given Degree and length find the full length of the Tree
Observe That the broken tree construct a 90 degree triangle ABD Where BD is hypotenuse
Also The Full length of tree is BD + AB = AD(1/sin(degree) + 1/tan(degree)
Sample c++ code:
ll t;
cin>>t;
while(t–){
double degre,len;
cin>>len>>degre;
cout<<setprecision(10)<<len*((1.0/tan((PIdegre)/180.0))+(1.0/sin((PIdegre)/180.0)))<<endl;
}

Problem B:
As it is confirmed that (g^i-1) %(N+1) will Generate a permutation of 1 - N
So First find the sequence
You may know (ab)%m =(a%m+b%m)%m …(i)
So For generating the sequence its 1%m,g%m, (g
g)%m,(ggg)%m,… where m = n+1
we use ith equation for generating the sequence
Now if a number is found whose previous one is the largest contiguous number (referred as curma in code) we see if the next number is visited or not untill we found a unvisited one .Thats the current largest contiguous number .Keep Xoring them as well to get the answer in one go

C++ sample code:
bool B;
int main()
{

ll n,g,rem=1,curma=1,ans=0;
cin>>g>>n;
for(int i=0;i<n;i++)
{
B[rem]=1;
if(rem-1==curma)
{
while(B[curma]==1)
curma++;
curma–;
}
ans^=curma;
rem*=(g%(n+1));
rem%=(n+1);
}
cout<<ans<<endl;
return 0;
}