QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#77322 | #5503. Euclidean Algorithm | vme50 | TL | 3ms | 3572kb | C++14 | 396b | 2023-02-14 08:41:34 | 2023-02-14 08:41:34 |
Judging History
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