QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#362734 | #8508. DiviDuelo | ucup-team3113# | RE | 6ms | 11200kb | C++20 | 1.2kb | 2024-03-23 16:56:04 | 2024-03-23 16:56:05 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
using namespace std;
const int inf = 1e18;
void p(auto A){
for(auto e : A)cout << e << ' ';
cout << '\n';
}
void solve(){
int n; cin >> n;
vector<int>is_prime((int)1e6+5);
for(int i = 2; i*i< is_prime.size(); i++)if(!is_prime[i]){
for(int j = i*i; j< is_prime.size(); j+= i)is_prime[j] = 1;
}
//for(int i = 1; i<= 100; i++)if(!is_prime[i])cout << i << ' ';
if(n == 1){
cout << 'N';
return;
}
int fl = 0;
for(int i = 2; i*i<= n; i++)if(n%i==0){
fl = 1;
break;
}
if(!fl){
cout << 'Y';
return;
}
for(int i = 2; i*i<= n; i++)if(n%i==0 && is_prime[i] && is_prime[n/i]){
cout << 'Y';
return;
}
for(int i = 1; i*i<= n; i++){
if(i*i == n){
//cout << !(is_prime[i]) << ' ' << (i*i == n && !(is_prime[i])) << endl;
cout << 'N';
return;
}
}
cout << 'Y';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--)solve();
}
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
详细
Test #1:
score: 100
Accepted
time: 6ms
memory: 11044kb
input:
10
output:
Y
result:
ok "Y"
Test #2:
score: 0
Accepted
time: 6ms
memory: 10908kb
input:
9
output:
N
result:
ok "N"
Test #3:
score: 0
Accepted
time: 5ms
memory: 11200kb
input:
1
output:
N
result:
ok "N"
Test #4:
score: -100
Runtime Error
input:
549755813888