CNFCT-EDITORIAL

PROBLEM LINK:

Practice
Contest: Hey Newbees, Here is Some Honey
Author: Samia Rahman
Tester: Arefin Labib
Tester: Nazmus Sakib Rhythm
Editorialist: Samia Rahman

DIFFICULTY:

SIMPLE.

PREREQUISITES:

Math,Geometry.

PROBLEM:

In the problem there is a given integer called N.You have to find out the Oddsum
and Evensum from 1 to N.There is also given a circle whose radius R is unknown
because you have to figure it out through N,where N is the arc length of the
circle.There is also a square given in the problem and you need to find out S ,where
S is a half diagonal of the square and N is another full diagonal of the square.Then
find out the LCM(oddsum,R) and LCM(evensum,S) and do compare them.

QUICK EXPLANATION:

Compare L1 and L2
Where,
L1=lcm(Oddsum,R)
L2=lcm(Evensum,S)
Oddsum=ceil(N/2)xceil(N/2)
Evensum=(N/2)x((N/2)+1)
R=ceil((2*N)/pi)
S=ceil(N/2)

EXPLANATION:

1.In case of Nova you need summation of odd numbers from 1 to N.Due to
shortness of time limit you need to figure this out with a formula.
Summation of odd numbers from 1 to N is-
Oddsum=ceil(N/2)xceil(N/2).

To find R -
N is the Arc Length of circle.
Formula of arc length-
S=rxθ
= arc length (in our code it is N)
= Radius (in our code it is R)
= central angle in radian (in our code it is θ)

So,
N=Rxθ
=Rx90 degree (WE NEED THE θ IN RADIAN)
=Rx90x(pi/180)
N=Rx(pi/2) //we all know that 90 degree=pi/2.
R=(2xN)/pi.
Take the ceil value of R.
LCM of Nova= (OddsumxR)/__gcd(Oddsum,R);

2.In case of Oliver Summation of odd numbers from 1 to N is-
Evensum=(N/2)x((N/2)+1).

To find S-
S is perpendicular on the middle point of the square’s diagonal N.
It’s a theorem that it will be N/2.

If you don’t know then apply Pythagoras formula-

square-of-my-code-3

Let’s assume side of the square is A.So N=Axsqrt(2).
So A =N/sqrt(2).
From Pythagoras formula-
A^2=(N/2)^2+S^2
Or,S^2=( N/sqrt(2))^2-(N/2)^2
=(N^2)/2-(N^2)/4
=(N^2)/4

S=sqrt((N^2)/4).
S=N/2.
Take the ceil value of S.
LCM of Oliver= (EvensumxS)/__gcd(Evensum,S);

TIME COMPLEXITY: O(1)

SOLUTIONS:

Setter's Solution
#include<bits/stdc++.h>
#define FastRead                      \
                                ios_base::sync_with_stdio(false); \
                                cin.tie(0);
#define ll long long
#define endl "\n"
#define pi acos(-1)
using namespace std;
int main()
{
    FastRead
    ll int t,j,n,e,o,m,g1,g2,l1,l2,r,s;
    double p;
    cin>>t;
    for(j=0; j<t; j++)
    {
        cin>>n;
        if(n%2==1)
            m=(n/2)+1;
        else
            m=n/2;
        e=(n/2)*((n/2)+1);
        o=m*m;
        p=(double)n;
        s=ceil(p/2);
        r=ceil((2*p)/pi);
        g1=__gcd(e,s);
        g2=__gcd(o,r);
        l1=(e*s)/g1;
        l2=(o*r)/g2;
        if(l1>l2)
            cout<<"Nova's gonna kill me"<<endl;
        else
            cout<<"YESS(sunglass emo)"<<endl;
    }
    return 0;
}
1 Like

Nice explanation :heart_eyes:

1 Like