3 条题解
-
1
#include <iostream> #include <cmath> using namespace std; long long Prime(long long n) { long long a = n; while (a > 9) { a /= 10; n = (n * 10 + a % 10); } return n; } int main() { long long t; cin >> t; long long n = Prime(t); bool isPrime = true; if (n < 2) { isPrime = false; } else { for (long long j = 2; j <= sqrt(n); j++) { if (n % j == 0) { isPrime = false; break; } } } if (isPrime) { cout << "prime\n"; } else { cout << "noprime\n"; } return 0; }
-
0
#include <bits/stdc++.h> using namespace std; #define ll long long void makehuiwen(ll &x) { ll t = x / 10; while (t) { ll s = t % 10; x = x * 10 + s; t /= 10; } } bool issushu(ll x) { for (int i = 2; i < x / 2; i++) { if (x % i == 0) { return false; } } return true; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll x; cin >> x; makehuiwen(x); if (issushu(x)) { cout << "prime"; } else { cout << "noprime"; } return 0; }
- 1
信息
- ID
- 112
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 131
- 已通过
- 27
- 上传者