QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694596#9248. An Easy Math ProblemxunxxxxTL 0ms3628kbC++231.4kb2024-10-31 18:17:062024-10-31 18:17:07

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:17:07]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3628kb
  • [2024-10-31 18:17:06]
  • Submitted

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())
    {
        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];
    }
}

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,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: 3628kb

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...

output:


result: