A single pamination Wrestling championship tournament will
be helds in the country. Champions from all over the world
participate to win the renowned tine! There is an incessant
of participants who are assembled in a row.
The 3 participants of the battle are numbered starting from 12531162 79
person with power 'P' can knock down other participants till
his power is reduced to less than the opponent's power.
Given the power of the person 'P', the task here is to find the
maximum number of participants he can eliminate from the
tournament.
Rules are :
an infinite number of participants.
a person with index 'i' in the row has the power i2
person A can fight with person B only if the power of A is i
greater than or equal to the power of B before the beginning
of each battle.
The power of person A reduces by value X which is equal to
the power of the opponent at the end of each battle
The battle ends when the power of the person get
Input:20
output 3
-→ Value of P
C++ Solution:-
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
int i=1;
while(n>=pow(i,2))
{
if(n>=pow(i,2))
n-=pow(i,2);
else
break;
i++;
}
cout<<i-1<<endl;
return 0;
}

0 Comments