QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619081 | #9248. An Easy Math Problem | ucup-team5071# | TL | 0ms | 3540kb | C++20 | 1.0kb | 2024-10-07 12:54:55 | 2024-10-07 12:54:56 |
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-07 12:54:55]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int solve()
{
int n;cin>>n;
// int n=1e10;
int ans=0;
auto insert= [&](int x,int y){
int g=gcd(x,y);
if(g==1)ans++;
};
for(int a=1;a*a<=n;a++)if(n%a==0){
int t=n/a;
vector<pair<int,int>> v;
for(int i=2;i*i<=t;i++){
int y=0;
while(t%i==0){
y++;t/=i;
}
if(y>0)v.emplace_back(i,y);
}
if(t>1)v.emplace_back(t,1);
function<void(int,int)> dfs = [&](int now,int i){
if(i==(int)v.size()){
if(now>=a)insert(a,now);
return;
}
for(int j=0;j<=v[i].second;j++){
dfs(now,i+1);
now*=v[i].first;
}
return;
};
dfs(1,0);
}
return ans;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;cin>>T;
while(T--)cout<<solve()<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
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...