#include <stdio.h>
#include <stdlib.h>
int main()
{
int n=0;
long x=0;
scanf("%d",&n);
while(n--){
scanf("%ld",&x);
if(x%2!=0){
x--;
}
printf("%ld\n",x/2);
}
return 0;
}
#include <stdlib.h>
int main()
{
int n=0;
long x=0;
scanf("%d",&n);
while(n--){
scanf("%ld",&x);
if(x%2!=0){
x--;
}
printf("%ld\n",x/2);
}
return 0;
}
hey bro, what is the formula, plz explain.
ReplyDeleteThere is no formula actually ... But logically let think ...
DeleteFirst of all let us confirm that 2 is the smallest factor of all numbers .. So the largest factor 'p' is the one which 2*p=the number ....if this number is even ... Then the greatest common factor will be this p ...
if the number is odd ... we will decrease 1 from the number ... So it become even and then we will find p ...
How we know this is the greatest common factor between n ...
As the odd number can't be divisible by 2 we can assure that
x/3 < (x-1)/2 for any x>1