QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89916#5503. Euclidean Algorithminstallb#TL 2ms3532kbC++20590b2023-03-21 19:33:052023-03-21 19:33:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-21 19:33:06]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:3532kb
  • [2023-03-21 19:33:05]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
ll x;int T;
ll sum(ll n){
    ll ans=0;
    for(ll l=1,r;l<=n;l=r+1){
        r=n/(n/l);
        ans+=(r-l+1)*(n/l);
    }
    return ans;
}
ll cal(ll n){
    ll ans=0;
    for(ll l=1,r;l<=n;l=r+1){
        r=n/(n/l);
        ans+=(r-l+1)*sum(n/l-1);
    }
    return ans;
}
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%lld",&x);
        printf("%lld\n",cal(x));
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3532kb

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: