Not at all… I would have found it after writing brute Force solution
!!!Math-God _/\_
u r joking …
thanks but I’m far away from being math god…
How to be good in maths in competitive programming?
I really don’t know… I love maths since 8th standard… I just did maths from 8th to 10th…
Same quetstion.
I_sees… !!! _/_
And there is usually a good deal of difference between CF and CC editorials.
what ??
…
Sir in question when to build roads, is it allow to build restaurant on the road
Just thought of this and thought it explains the formula pretty well.
a + b + a * b = (a + 1) * (b + 1) - 1.
Now, for ((a, b) , c) , we can substitute the above result as ((a + 1) * (b + 1) - 1, c)
Expanding this we get (a + 1) * (b + 1) * (c + 1) - 1. Hence, no matter how many operations you do and in what order you do, you will get (a + 1) * (b + 1) * (c + 1) * … - 1. Since the numbers here go from 1 to N, our answer become (1 + 1) * ( 2 + 1) * (3 + 1) * … * (N + 1) - 1. This is essentially (N + 1)! - 1.
Hope this helps.
Let (a + 1) * (b + 1) - 1 = d
Then, (d, c) = (d + 1) * ( c + 1) - 1
But d = ( a + 1 ) * ( b + 1) - 1 .
Hence, (d + 1) = ( a + 1) * ( b + 1)
Hence, (d, c) = (a + 1) * (b + 1) * (c + 1) - 1
Please provide the link for your editorials.
404
Post must be at least 20 characters
@vijju123 @I_returns can anyone plz find the error in this code for MATCHES problem
thanks in advance!!..
#include <math.h>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int maximum(int a,int b)
{
if(a>b)
return a;
else
return b;
}
int minimum(int a,int b)
{
if(a>b)
return b;
else
return a;
}
int main()
{
ll t;
cin>>t;
while(t–)
{
ll i,n,m,a,b,k;
cin>>n>>m;
i=0;
while(n!=0&&m!=0)
{
i++;
a=minimum(n,m);
if(a==m)
{
n=n%m;
}
else
{
m=m%n;
}
}
if((i-1)%2==0)
{
cout<<"Ari"<<endl;
}
else
{
cout<<"Rich"<<endl;
}
}
}
Here is the editorial:-