QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#77322#5503. Euclidean Algorithmvme50TL 3ms3572kbC++14396b2023-02-14 08:41:342023-02-14 08:41:34

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-14 08:41:34]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:3572kb
  • [2023-02-14 08:41:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int T;ll n,ans;
ll f(ll n)
{
    ll res=0;
    for(ll i=1,j,t;i<=n;i=j+1)
        t=n/i,j=n/t,res+=t*(j-i+1);return res;
}
void slv()
{
    scanf("%lld",&n);ans=0;
    for(ll i=1,j,t;i<=n;i=j+1)
        t=n/i,j=n/t,ans+=f(t-1)*(j-i+1);printf("%lld\n",ans);
}
int main() {scanf("%d",&T);while(T--) slv();return 0;}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3572kb

input:

3
2
5
14

output:

1
9
62

result:

ok 3 lines

Test #2:

score: -100
Time Limit Exceeded

input:

3
29107867360
65171672278
41641960535

output:


result: