QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#136833#241. Chiaki Sequence RevisitedOrange_JuiCE#Compile Error//Python31.2kb2023-08-09 12:26:342023-08-09 12:26:36

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 12:26:36]
  • 评测
  • [2023-08-09 12:26:34]
  • 提交

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();
    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*(((a+1)/2)%P)%P*(((a+1)/2)%P)%P)%P;
        r = r*2%P, a >>= 1ll, q++;
    }
    printf("%lld\n", ans);
}


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

詳細信息

  File "answer.code", line 24
    x >>= 1ll;
          ^
SyntaxError: invalid decimal literal