here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Tuesday 9 June 2015

Playing with isosceles triangle

problem statement is here


#include<stdio.h>
#include<math.h>
 int main() {
long int n,t,s,flag,i,c;
scanf("%ld", &t);
while(t--) {
scanf("%ld",&s);
flag=0;
if(s%2==0){
while(s%2==0)
s=s/2;
}
n=(sqrt(s));
for(i=3;i<=n;i+=2){
if(s%i==0){
if(i%4==1)
flag = 1;
while(s%i==0)
s=s/i;
}
if(s==1)
break;
}
if(s!=1&&s%4==1)
flag=1;
if(flag==0){
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}

No comments:

Post a Comment