QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89920#5500. Barsinstallb#WA 44ms9392kbC++20786b2023-03-21 19:40:522023-03-21 19:40:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-21 19:40:55]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:9392kb
  • [2023-03-21 19:40:52]
  • 提交

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'