QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#64111#5115. Clone RanranDaBenZhongXiaSongKuaiDi#AC ✓686ms3568kbC++20722b2022-11-24 09:07:102022-11-24 09:07:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-24 09:07:12]
  • 评测
  • 测评结果:AC
  • 用时:686ms
  • 内存:3568kb
  • [2022-11-24 09:07:10]
  • 提交

answer

#include <bits/stdc++.h>,
//#define int long long
#define ll long long
#define db double
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define i128 __int128
using namespace std;
int a,b,c;

int check(i128 x) {
	i128 pw=1,num=0; 
	for (i128 o=0;;) {
		i128 sheng=x-o;
		i128 t=sheng/b;
		t=t*pw;
		if (t>=c) return 1;
		if (pw>c) break ; 
		pw*=2,o+=a; 
	}
	return 0;
}
void solve() {
	scanf("%d %d %d",&a,&b,&c); 
	i128 l=1,r=1e13; ll ans; 
	while (l<=r) {
		i128 mid=(l+r)>>1;
		if (check(mid)) {
			ans=mid; 
			r=mid-1; 
		} else l=mid+1; 
	}
	cout<<ans<<'\n'; 
}
int main() {
	int T; 
	scanf("%d",&T);
	while (T--) solve(); 
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3448kb

input:

5
1 1 1
2 3 3
9 9 9
3 26 47
1064 822 1048576

output:

1
7
45
44
21860

result:

ok 5 number(s): "1 7 45 44 21860"

Test #2:

score: 0
Accepted
time: 686ms
memory: 3568kb

input:

99500
1000000000 1000000000 1000000000
1000000000 1000000000 999999999
1000000000 1000000000 999999998
1000000000 1000000000 999999997
1000000000 1000000000 999999996
1000000000 1000000000 999999995
1000000000 1000000000 999999994
1000000000 1000000000 999999993
1000000000 1000000000 999999992
10000...

output:

31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999996
30999999996
30999999996
30999999996
30999999996
...

result:

ok 99500 numbers