QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#76855#5503. Euclidean AlgorithmLYC_musicTL 13995ms7292kbC++141.2kb2023-02-12 13:32:582023-02-12 13:32:59

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:32:59]
  • 评测
  • 测评结果:TL
  • 用时:13995ms
  • 内存:7292kb
  • [2023-02-12 13:32:58]
  • 提交

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;
ll n, ans;
int g[B+5];
inline ll query(ll X)
{
    if (X <= B)
        return g[X];
    ll Y = 0;
    for (ll L = 1; L < X; L++)
    {
        ll R = X / (X / L);
        Y += (R - L + 1) * ((X / L) - 1);
        L = R;
    }
    return Y;
}
void BellaKira()
{
    cin >> n;
    ans = 0;
    for (ll l = 1; l < n; l++)
    {
        ll r = n / (n / l);
        r = min(r, n - 1);
        ll X = ((n / l) - 1);
        ll Y = query(X);
        ans += Y * (r - l + 1);
        l = r;
    }
    ans+=query(n);
    cout << ans << '\n';
}
signed main()
{
    IOS;
    cin.tie(0);
    ll T = 1;
    cin >> T;
    for (ll X = 1; X <= B; ++X)
    {
    	for (ll Y=X+X;Y<=B;Y+=X)
    		g[Y]+=1;
    	g[X]+=g[X-1];
    }
    // cout<<g[B]<<'\n';
    // return 0;
    while (T--)
    {
        BellaKira();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 22ms
memory: 7292kb

input:

3
2
5
14

output:

1
9
62

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 13995ms
memory: 7180kb

input:

3
29107867360
65171672278
41641960535

output:

8921593237533
21300450379732
13136180138425

result:

ok 3 lines

Test #3:

score: -100
Time Limit Exceeded

input:

3
90076809172
100000000000
99913139559

output:


result: