#include <iostream> #include <cmath> using namespace std; int pd[4010], q[4010], cnt; void f4000(void)//4000以下的素数,线性筛 { for (int i = 2; i <= 4000; ++i) { if (!pd[i]) for (int j = i * 2; j <= 4000; j += i) pd[j] = 1; } for (int i = 2; i <= 4000; ++i) if (!pd[i]) q[++cnt] = i; } int pf(long long n) { long long num = sqrt(n); while (num * num <= n) { if (num * num == n)return 1; ++num; } return 0; } int lf(long long n) { long long num = pow(n, 1.0 / 3); while (num * num * num <= n) { if (num * num * num == n) return 1; ++num; } return 0; } int t, a;// t是输入数字个数,a和k是主函数用到的变量 long long shuzi[100005], k; int main() { f4000(); scanf("%d", &t); for (int i = 1; i <= t; ++i)scanf("%lld", shuzi + i); for (int i = 1; i <= t; ++i) { int flag = 1; k = shuzi[i]; if (lf(k) || pf(k)) { printf("yes\n"); continue; } for (int j = 1; j <= cnt; ++j) { a = 0; while (k % q[j] == 0) { k /= q[j]; ++a; } if (a == 1) { flag = 0; break; } } if (flag && (lf(k) || pf(k))) printf("yes\n"); else printf("no\n"); } return 0; }
0.0分
3 人评分
点我有惊喜!你懂得!浏览:1392 |
C语言训练-求矩阵的两对角线上的元素之和 (C语言代码)浏览:3472 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1019 |
C语言程序设计教程(第三版)课后习题8.2 (Java代码)浏览:2287 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1550 |
C语言训练-计算:t=1-1/(2*2)-1/(3*3)-...-1/(m*m) (C语言代码)浏览:799 |
【计算两点间的距离】 (C语言代码)浏览:927 |
简单的a+b (C语言代码)浏览:600 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:574 |
简单的a+b (C语言代码)浏览:457 |