QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77687#5503. Euclidean Algorithmchenshi#TL 1ms1764kbC++401b2023-02-15 12:57:422023-02-15 12:57:45

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-15 12:57:45]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:1764kb
  • [2023-02-15 12:57:42]
  • 提交

answer

#include<cstdio>
using namespace std;
int z;long long n,ans;
inline long long sd(long long n){
	long long res=0;
	for(long long i=1,j;i<=n;i=j+1) j=n/(n/i),res+=n/i*(j-i+1ll);
	return res;
}
int main(){
	for(scanf("%d",&z);z--;printf("%lld\n",ans),ans=0){
		scanf("%lld",&n);
		ans=sd(n)-n;
		for(long long i=2,j;i<=n;i=j+1) j=n/(n/i),ans+=n/i*(sd(j-1)-sd(i-2)-(j-i+1));
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 1764kb

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: