QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637308#9248. An Easy Math Problemblue_sky#TL 0ms3872kbC++201.9kb2024-10-13 12:05:172024-10-13 12:05:18

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-13 12:05:18]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3872kb
  • [2024-10-13 12:05:17]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define bug(X) cout << "bug:# " << X << endl
#define bug2(f, X) cout << "bug:# " << f << " " << X << endl
#define bug3(i, j, G) cout << "bug:# " << i << ' ' << j << ' ' << G << endl
#define endl '\n'
using namespace std;
const int mod = 1e11 + 3;
const int N = 10 + 5e5;
void _();
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        _();
    return 0;
}

map<int, vector<int>> Y;
void _()
{
    int n;
    cin >> n;
    // n=1e10;
    int cnt = 0;
    vector<int> yin;
    map<pair<int, int>, int> res;
    for (int i = 1; i <= n / i; i++)
        if (n % i == 0)
        {
            cnt += n / i == i ? 1 : 2;
            yin.push_back(i);
            if (n / i - i)
                yin.push_back(n / i);
            res[{1, i}]++;
            res[{1, n / i}]++;
        }
    // map<int,int> special;
    for (auto v : yin)
    {
        if (Y.count(v))
        {
            for(auto y:Y[v])
                {
                    int g = __gcd(y, v / y);
                    // if(i<=v/i&&!res.count({i/g,v/i/g})) special[v]=1;
                    if (y <= v / y)
                        res[{y / g, v / y / g}]++;
                }
        }
        else 
        for (int i = 2; i <= n / i; i++)
            if (v % i == 0)
            {
                Y[v].push_back(i);
                int g = __gcd(i, v / i);
                // if(i<=v/i&&!res.count({i/g,v/i/g})) special[v]=1;
                if (i <= v / i)
                    res[{i / g, v / i / g}]++;
            }
    }
    // for (auto [v, c] : special)
    //     cout << v << ' ';
    // cout << endl;
    // for (auto [V, _] : res)
    //     bug2(V.x, V.y);
    cout << res.size() << endl;
    // bug3(res.size(), cnt, res.size() - cnt);
}

详细

Test #1:

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

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: