QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692517 | #9248. An Easy Math Problem | Core_65536# | TL | 77ms | 5472kb | C++23 | 1.9kb | 2024-10-31 14:39:01 | 2024-10-31 22:43:15 |
Judging History
你现在查看的是最新测评结果
- [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:39:01]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define int long long
vector<int>ans;
vector<__int128>res;
unordered_map<int,int>mp;
void dfs(int i,__int128 res1)
{
if(i==ans.size())
{
// cout<<res1<<"\n";
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;
// }
// }
// }
map<int,int>mp1;
void solve()
{
int n;
cin>>n;
if(mp1.count(n))
{
cout<<mp1[n]<<"\n";
return ;
}
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) 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[tn]=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();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 0
Accepted
time: 8ms
memory: 5472kb
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...
output:
29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 29525 ...
result:
ok 2000 lines
Test #3:
score: 0
Accepted
time: 77ms
memory: 4132kb
input:
2000 1763047095 79735483 1016286871 2864801397 2327774116 2668010360 3469893354 3634459021 1613699068 781737219 574741575 2763134701 1458502604 1822260248 2281150332 2924219311 2493931196 3735904708 158802001 2006921221 729928782 1974841034 727412600 2873393292 1291087179 2741607663 1893408215 29827...
output:
14 5 2 5 23 95 68 14 8 68 203 14 23 32 38 41 8 8 14 2 608 41 158 338 23 41 14 5 14 41 14 203 41 14 17 446 5 53 59 878 2 14 365 203 14 203 2 122 32 95 41 41 5 23 14 41 5 5 14 122 23 203 608 23 41 122 2 14 95 2 68 41 203 14 230 41 68 23 50 14 32 14 8 5 5 5 68 68 122 293 473 5 41 41 14 2 14 14 5 2 122 ...
result:
ok 2000 lines
Extra Test:
score: -3
Extra Test Failed : Time Limit Exceeded on 4
input:
2000 10000000000 9999980000 9999960000 9999940000 9999920000 9999900000 9999880000 9999860000 9999840000 9999820000 9999800000 9999780000 9999760000 9999740000 9999720000 9999700000 9999680000 9999660000 9999640000 9999620000 9999600000 9999580000 9999560000 9999540000 9999520000 9999500000 99994800...