UVA1180
COsm0s
·
·
题解
套用完全数公式。
已知 p 为素数,且 2^p-1 也为一个素数,则 2^{p-1} \times (2^p-1) 为完全数。
## Code
```cpp
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, p;
char c;
inline bool prime(int x) {
if(x < 2) return 0;
for(int i = 2; i * i <= x; i ++)
if(x % i == 0) return 0;
return 1;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i ++) {
cin >> p;
if(i < n) cin >> c;
if((prime(p)) && prime((int)pow(2, p) - 1)) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
```