QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692101 | #9248. An Easy Math Problem | Core_65536# | TL | 0ms | 3556kb | C++20 | 1.5kb | 2024-10-31 13:49:03 | 2024-10-31 13:49:04 |
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 13:49:03]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define int long long
vector<int>ans;
vector<int>path;
vector<int>res;
map<int,int>mp;
void dfs(int i)
{
if(path.size()==ans.size())
{
int res1=1;
for(int j=0;j<path.size();j++)
{
int t=path[j];
while(t--) res1=res1*ans[j];
}
res.push_back(res1);
return ;
}
for(int j=0;j<=mp[ans[i]];j++)
{
path.push_back(j);
dfs(i+1);
path.pop_back();
}
}
void solve()
{
int n;
cin>>n;
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);
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(tn%(res[i]*res[j])==0)
{
int g=__gcd(res[i],res[j]);
st.insert({res[i]/g,res[j]/g});
}
if(res[i]*res[j]>tn) break;
}
}
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();
}
return 0;
}
详细
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...