QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382081#8508. DiviDuelokevinshan#RE 0ms0kbC++171.7kb2024-04-08 02:04:392024-04-08 02:04:41

Judging History

你现在查看的是最新测评结果

  • [2024-04-08 02:04:41]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-08 02:04:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define For(i,a) FOR(i,0,a)
#define trav(a,b) for(auto& a:b)
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define lb lower_bound
#define bk back()
#define sz(x) (int) x.size()
#define vpi vector<pi>

const int MX = 1e6+5;

bool is_pr[MX];

void solve() {

}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    For(i,MX) is_pr[i] = true;

    ll n;
    cin>>n;
    if(n==1) {
        cout << 'N' << endl;
        return 0;
    }
    // cout << "N: " << n << endl;
    vpi v;
    FOR(i,2,MX+1) if(is_pr[i]) {
        for(int p=2*i;p<MX;p+=i)
            is_pr[p]=false;
        
        int cnt=0;
        while(n%i==0) {
            n/=i;
            cnt++;
        }  
        if(cnt) {
            // cout << "A" << i << " " << cnt << endl;
            v.pb({i,cnt});
        }
    }
    if(n>1) {
        v.pb({n,1});
    }
    
    if(sz(v)>=3) {
        cout << 'N' << endl;
    } else if(sz(v)==2) {
        if(v[0].s==1 && v[1].s==1) {
            cout << 'Y' << endl;
        } else {
            cout << 'N' << endl;
        }
    } else {
        assert(sz(v)==1);
        if(v[0].s%2==1) {
            cout << 'Y' << endl;
        } else {
            cout << 'N' << endl;
        }
    }





}


详细

Test #1:

score: 0
Runtime Error

input:

10

output:


result: