QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#136833 | #241. Chiaki Sequence Revisited | Orange_JuiCE# | Compile Error | / | / | Python3 | 1.2kb | 2023-08-09 12:26:34 | 2023-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]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [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;
}
Details
File "answer.code", line 24 x >>= 1ll; ^ SyntaxError: invalid decimal literal