QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77689#5503. Euclidean Algorithmchenshi#ML 0ms0kbC++555b2023-02-15 13:02:182023-02-15 13:02:20

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 13:02:20]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-02-15 13:02:18]
  • 提交

answer

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

詳細信息

Test #1:

score: 0
Memory Limit Exceeded

input:

3
2
5
14

output:

1
9
62

result: