QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692335 | #9248. An Easy Math Problem | Core_65536# | TL | 0ms | 3844kb | C++23 | 1.9kb | 2024-10-31 14:20:22 | 2024-10-31 14:20:23 |
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 14:20:22]
- 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>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];
}
}
// bool is[100000010];
// vector<int>pr;
// void init()
// {
// for(int i=2;i<=1e8;i++)
// {
// if(!is[i]) pr.push_back(i);
// for(int j=0;j<pr.size()&&pr[j]*i<=1e8;j++)
// {
// is[pr[j]*i]=1;
// if(i%pr[j]==0) break;
// }
// }
// }
void solve()
{
int n;
cin>>n;
int tn=n;
if(n==1)
{
cout<<"1\n";
return ;
}
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) cout<<i.first<<" "<<i.second<<"\n";
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});
}
}
}
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: 3844kb
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...