QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136930#241. Chiaki Sequence RevisitedOrange_JuiCECompile Error//C++141.2kb2023-08-09 14:13:142023-08-09 14:13:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-09 14:13:16]
  • 评测
  • [2023-08-09 14:13:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int ll

int read(){
    int red=0, f_f=1; char c=getchar();
    while (c<'0'||c>'9'){if (c=='-')f_f=-1;c=getchar();}
    while (c>='0'&&c<='9'){red=(red<<1)+(red<<3)+(c^48);c=getchar();}
    return f_f*red;
}

const int N = 1e5+5;
const int P = 1e9+7;

int n, a, r, q;
int ans;

int calc(int x) {
    int re = x;
    while(x) {
        x >>= 1ll;
        re += x;
    }
    return re;
}

int find(int x) {
    int l = 1ll, r = 5e17+20, re = 0;
    while(l <= r) {
        int mid = (l+r)>>1ll, cc = calc(mid);
        if(cc == x) return mid;
        if(cc < x) re = mid, l = mid+1;
        else r = mid-1;
    }
    return re;
}

void solve() {
n = read();
cnt++;
if(cnt==10001) printf("%d",n);
    n--, ans=1, r=1, q=1;
    if(!n) {
        printf("1\n");
        return;
    }
    a = find(n);
    ans = (ans+(n-calc(a))%P*((a+1)%P)%P)%P;
    while(a) {
        ans = (ans+q*r%P*(((a+1)/2)%P)%P*(((a+1)/2)%P)%P)%P;
        r = r*2ll%P, a >>= 1ll, q++;
    }
    printf("%lld\n", ans);
}


signed main() {
    int T = read();
    while (T--) {
        solve();
    }
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:43:1: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   43 | cnt++;
      | ^~~
      | int
answer.code:44:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   44 | if(cnt==10001) printf("%d",n);
      |                        ~^  ~
      |                         |  |
      |                         |  long long int
      |                         int
      |                        %lld