QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155553#5503. Euclidean Algorithm275307894aWA 4459ms3808kbC++14975b2023-09-01 20:01:282023-09-01 20:01:28

Judging History

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

  • [2023-09-01 20:01:28]
  • 评测
  • 测评结果:WA
  • 用时:4459ms
  • 内存:3808kb
  • [2023-09-01 20:01:28]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e6+5,M=N*4+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
ll n;
ll calc(ll x){
	ll ans=0;
	for(ll i=1;i*i<=x;i++) ans+=x/i*2-i*2+1;
	return ans;
}
void Solve(){
	ll i,j;scanf("%lld",&n);
	ll ans=0;
	// cerr<<calc(4)<<'\n';
	for(i=2;i<=n;i=j+1){
		j=n/(n/i);
		ans+=n/i*(calc(j-1)-calc(i-2));
	} 
	printf("%d\n",ans);
}
int main(){
	int t;
	scanf("%d",&t);
	// t=1;
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2
5
14

output:

1
9
62

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 4459ms
memory: 3768kb

input:

3
29107867360
65171672278
41641960535

output:

946163741
1707558868
-2124820039

result:

wrong answer 1st lines differ - expected: '8921593237533', found: '946163741'