QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834500 | #9248. An Easy Math Problem | yolo_lyc | TL | 23ms | 24312kb | C++20 | 1.1kb | 2024-12-27 18:49:18 | 2024-12-27 18:49:19 |
Judging History
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...