QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676005#9248. An Easy Math ProblemGordensoul#TL 0ms3536kbC++171.0kb2024-10-25 19:55:522024-10-25 19:55:52

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-25 19:55:52]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3536kb
  • [2024-10-25 19:55:52]
  • Submitted

answer

#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using ll = long long;
typedef unsigned long long ull;
using namespace std;
int gcd(int a,int b)
{
if(a==0)return b;
return gcd(b%a,a);
}
void GordenGhost();

signed main() {
#ifdef Gorden
    freopen("in.txt", "rt", stdin);
    freopen("out.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    GordenGhost();
    return 0;
}

void GordenGhost() {
    ll q,ff=0;
    cin>>q;
    while (q--){
        ff++;
        ll n,ans=0;
        cin>>n;
        vector<ll>w;
        ll en= sqrt(n);
        for (int i = 1; i <= en; ++i) {
            if (n%i==0){
                w.push_back(i);
                if (n/i!=i) w.push_back(n/i);
            }
        }
int sz=w.size();
        for (int i = 0; i < sz; ++i) {
            for (int j = i; j < sz; ++j) {
                if (w[i]*w[j]>n) break;
                if (gcd(w[i],w[j])==1&&n%(w[i]*w[j])==0) ans++;
            }
        }
        cout<<ans<<'\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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: