QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834500#9248. An Easy Math Problemyolo_lycTL 23ms24312kbC++201.1kb2024-12-27 18:49:182024-12-27 18:49:19

Judging History

This is the latest submission verdict.

  • [2024-12-27 18:49:19]
  • Judged
  • Verdict: TL
  • Time: 23ms
  • Memory: 24312kb
  • [2024-12-27 18:49:18]
  • Submitted

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
#define fi first 
#define se second
#define all(v) v.begin(),v.end()
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f;
const int N = 1e6+5;
int n;
int vis[N];
int st[N];
map<int,int>mp;

void cal(int x){
	for(int i=2;i<=x;i++){
		if(!vis[i]){
			mp[i] = 1;
			for(int j=i;j<=x;j+=i){
				vis[j]=1;
			}		
		}
	}
}

void solve(){
    cin>>n;
    memset(st,0,sizeof(st));
    int ans = 0;

    int cnt = 0;
    vector<int>aa;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
            if(mp[i] && !st[i]){
                ans++;
                st[i] = 1;
            }
			aa.push_back(i);
			if(i==n/i)continue;
			aa.push_back(n/i);
            if(mp[n/i] && !st[n/i]){
                ans++;
                st[n/i] = 1;
            }
		}
	}
    cnt = (int)aa.size();

    //cout<<"pre="<<ans<<"\n";

    ans = cnt + (ans)*(ans-1)/2LL;
    cout<<ans<<"\n";

    
}

signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T = 1;
    cin>>T;
    cal(N-5);
    while(T--){
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 23ms
memory: 24312kb

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:


result: