QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89920 | #5500. Bars | installb# | WA | 44ms | 9392kb | C++20 | 786b | 2023-03-21 19:40:52 | 2023-03-21 19:40:55 |
Judging History
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;
const int N=1.5e6;
ll x;int T,f[N+10];
ll sum(ll n){
if(n<=N) return f[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;
}
void pre(int n){
rep(i,1,n) rep(j,1,n/i) f[i*j]++;
rep(i,1,n) f[i]+=f[i-1];
}
int main(){
//cerr << sizeof(f)/1024/1024 << endl;
scanf("%d",&T);pre(N);
while(T--){
scanf("%lld",&x);
printf("%lld\n",cal(x));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 44ms
memory: 9392kb
input:
2 4 5 2 2 6 5 1 5 4 4 1
output:
6 9
result:
wrong answer 1st lines differ - expected: '33', found: '6'