QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#694640 | #9248. An Easy Math Problem | xunxxxx | TL | 0ms | 3556kb | C++23 | 1.4kb | 2024-10-31 18:23:02 | 2024-10-31 18:23:03 |
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-31 18:23:02]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int>ans;
vector<int>res;
unordered_map<int,int>mp;
void dfs(int i,int res1)
{
if(i==ans.size())
{
res.push_back(res1);
return ;
}
for(int j=0;j<=mp[ans[i]];j++)
{
int j1=j;
while(j1--) res1*=ans[i];
dfs(i+1,res1);
j1=j;
while(j1--) res1/=ans[i];
}
}
map<int,int>mp1;
void solve()
{
int n;
cin>>n;
if(mp1.count(n))
{
cout<<mp1[n]<<"\n";
return ;
}
int tn=n;
mp.clear();
for(int i=2;i*i<=n;i++)
{
if(n%i==0)
{
while(n%i==0)
{
n/=i;
mp[i]++;
}
}
}
if(n!=1) mp[n]++;
ans.clear();
res.clear();
for(auto i:mp) ans.push_back(i.first);
dfs(0,1);
sort(res.begin(),res.end());
set<pair<int,int>>st;
for(int i=0;i<res.size();i++)
{
for(int j=i;j<res.size();j++)
{
if(res[i]*res[j]>tn) break;
if(tn%(res[i]*res[j])==0)
{
int g=__gcd(res[i],res[j]);
st.insert({res[i]/g,res[j]/g});
}
}
}
mp1[n]=st.size();
cout<<st.size()<<"\n";
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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...