阅读题。。加上等差数列判断。。
#include<cstdio> #include<cmath> int n,s; int main(){ while(scanf("%d",&n)&&n!=-1){ n--; if (n%6){printf("N\n");continue;} n/=3; s=int (sqrt(double(n))); if (s*(s+1)==n)printf("Y\n"); else printf("N\n"); } }
时间: 2024-10-16 17:26:47
阅读题。。加上等差数列判断。。
#include<cstdio> #include<cmath> int n,s; int main(){ while(scanf("%d",&n)&&n!=-1){ n--; if (n%6){printf("N\n");continue;} n/=3; s=int (sqrt(double(n))); if (s*(s+1)==n)printf("Y\n"); else printf("N\n"); } }