QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645526#9248. An Easy Math ProblemqkyTL 0ms3648kbC++171.2kb2024-10-16 18:51:492024-10-16 18:51:49

Judging History

This is the latest submission verdict.

  • [2024-10-31 22:36:43]
  • hack成功,自动添加数据
  • (/hack/1098)
  • [2024-10-31 22:13:58]
  • hack成功,自动添加数据
  • (/hack/1096)
  • [2024-10-31 22:00:43]
  • hack成功,自动添加数据
  • (/hack/1095)
  • [2024-10-16 18:51:49]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3648kb
  • [2024-10-16 18:51:49]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e4+1;
ll fac[N];
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
map<pair<ll,ll>,int> mp;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        ll n;cin>>n;
        mp.clear();
        int cnt=0;
        for(ll i=1;i*i<=n;i++){
            if(n%i==0){
                if(i*i==n) fac[++cnt]=i;
                else {
                    fac[++cnt]=i;
                    fac[++cnt]=n/i;
                }
            }
        }
        ll ans=0;
        sort(fac+1,fac+cnt+1);
        for(int i=1;i<=cnt;i++){
            ll x=fac[i];
            for(ll j=1;j*j<=x;j++){
                if(x%j==0){
                        ll a=j,b=x/j;
                        a=a/gcd(a,b);
                        b=b/gcd(a,b);
                        if(mp[make_pair(a,b)]==0){
                            ans++;
                            mp[make_pair(a,b)]=1;
                        }
                }
            }
        }
        cout<<ans<<endl;
        //for(auto it:mp){
        //    cout<<it.first.first<<" "<<it.first.second<<endl;
        //}
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
3
2
5
2
4
3
5

result:

ok 10 lines

Test #2:

score: -100
Time Limit Exceeded

input:

2000
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
646969323...

output:

29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
...

result: