QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#76850#5503. Euclidean AlgorithmLYC_musicML 0ms0kbC++141.4kb2023-02-12 13:29:062023-02-12 13:29:37

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-12 13:29:37]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-02-12 13:29:06]
  • 提交

answer

#include <bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair<int, int>
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define int ll
#define N 1005
using namespace std;
const int B=1000000;
int n, ans, g[B+5];
int query(int X)
{
    if (X <= B)
        return g[X];
    int t = n / X;
    int Y = 0;
    for (int L = 1; L < X; L++)
    {
        int R = X / (X / L);
        Y += (R - L + 1) * ((X / L) - 1);
        L = R;
    }
    return Y;
}
void BellaKira()
{
    cin >> n;
    ans = 0;
    for (int l = 1; l < n; l++)
    {
        int r = n / (n / l);
        r = min(r, n - 1);
        int X = ((n / l) - 1);
        int Y = query(X);
        ans += Y * (r - l + 1);
        l = r;
    }
    ans+=query(n);
    // for (int l = 1; l < n; l++)
    // {
        // int r = n / (n / l);
        // r = min(r, n - 1);
        // ans += (r - l + 1) * ((n / l) - 1);
        // l = r;
    // }
    cout << ans << '\n';
}
signed main()
{
    IOS;
    cin.tie(0);
    int T = 3;
    cin >> T;
    for (int X = 1; X <= B; ++X)
    {
    	for (int Y=X+X;Y<=B;Y+=X)
    		g[Y]+=1;
    	g[X]+=g[X-1];
    	// cout<<X<<" "<<g[X]<<'\n';
    }
    while (T--)
    {
        BellaKira();
    }
}

详细

Test #1:

score: 0
Memory Limit Exceeded

input:

3
2
5
14

output:


result: