社区讨论
36 pts 压位高精求调,玄 3 关
P1431找出伪币参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mli52snf
- 此快照首次捕获于
- 2026/02/11 22:42 上周
- 此快照最后确认于
- 2026/02/14 09:25 5 天前
CPP
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5, M = 1e9;
struct bigint{
int n, a[N];
void read(string s){
int t = s.size(), x = 0, cnt = 1; n = 0;
for (int i = t - 1; i >= 0; i -- ){
x = x + cnt * (s[i] - '0'), cnt *= 10;
if (cnt == M) cnt = 1, a[++ n] = x, x = 0;
}
if (cnt > 1) a[++ n] = x;
}
void print(){
for (int i = n; i >= 1; i -- ) cout << a[i] << ",";
cout << "\n";
}
bigint operator +(const bigint &x){
bigint ans; int t = 0;
for (int i = 1; i <= n || i <= x.n || t; i ++ ){
t += a[i], t += x.a[i];
ans.a[i] = t % M; t /= M;
ans.n = i;
}
return ans;
}
bigint operator +(const int &x){
bigint ans; int t = x;
for (int i = 1; i <= n || t; i ++ ){
t += a[i];
ans.a[i] = t % M; t /= M;
ans.n = i;
}
return ans;
}
bigint operator *(const int &x){
bigint ans; int t = 0;
for (int i = 1; i <= n || t; i ++ ){
t += a[i] * x;
ans.a[i] = t % M; t /= M;
ans.n = i;
}
return ans;
}
bool operator <(const bigint &x){
if (n < x.n) return true;
if (n > x.n) return false;
for (int i = n; i >= 1; i -- ){
if (a[i] > x.a[i]) return false;
if (a[i] < x.a[i]) return true;
}
return false;
}
bool operator >(const bigint &x){
if (n > x.n) return true;
if (n < x.n) return false;
for (int i = n; i >= 1; i -- ){
if (a[i] < x.a[i]) return false;
if (a[i] > x.a[i]) return true;
}
return false;
}
bool operator ==(const bigint &x){
if (n < x.n) return false;
if (n > x.n) return false;
for (int i = n; i >= 1; i -- ){
if (a[i] > x.a[i]) return false;
if (a[i] < x.a[i]) return false;
}
return true;
}
bool operator >=(const bigint &x){
if (n > x.n) return true;
if (n < x.n) return false;
for (int i = n; i >= 1; i -- ){
if (a[i] < x.a[i]) return false;
if (a[i] > x.a[i]) return true;
}
return true;
}
bool operator <=(const bigint &x){
if (n < x.n) return true;
if (n > x.n) return false;
for (int i = n; i >= 1; i -- ){
if (a[i] > x.a[i]) return false;
if (a[i] < x.a[i]) return true;
}
return true;
}
};
signed main(){
int T; cin >> T;
while (T -- ){
int k, p; string n; cin >> k >> p >> n;
bigint a; a.read(n);
if (p == 0) a = a * 2 + 3;
bigint now; now.n = 1, now.a[1] = 1;
int ans = 0;
while (a > now) ans ++, now = now * 3;
cout << ans << "\n";
}
}
昨天用 python 死活跳不过去,还是这句话,恒久没熬这么晚了,求调,救救我吧。
回复
共 3 条回复,欢迎继续交流。
正在加载回复...