QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#509671#5721. Dividing by TwoexxqfuAC ✓0ms1324kbC++14621b2024-08-08 17:05:272024-08-08 17:05:28

Judging History

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

  • [2024-08-08 17:05:28]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:1324kb
  • [2024-08-08 17:05:27]
  • 提交

answer

#include <cstdio>
#define rep(i, d, u) for(int i = d; i <= u; ++i)
int ured() {
	int ch, re = 0;
	do {
		ch = getchar();
	} while(ch < '0' || '9' < ch);
	do {
		re = re * 10 + (ch ^ '0');
	} while('0' <= (ch = getchar()) && ch <= '9');
	return re;
}
void uwit(int da) {
	int ch[21], cn = 0;
	do {
		ch[++cn] = da % 10;
	} while(da /= 10);
	do {
		putchar('0' ^ ch[cn]);
	} while(--cn);
}
int a, b, rans;
int main() {
	a = ured(), b = ured();
	while(a > b) {
		if(a & 1) {
			a = a + 1 >> 1, rans += 2;
		} else {
			a >>= 1, ++rans;
		}
	}
	uwit(rans + b - a), putchar('\n');
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 1240kb

input:

103 27

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1296kb

input:

3 8

output:

5

result:

ok single line: '5'

Test #3:

score: 0
Accepted
time: 0ms
memory: 1244kb

input:

1010 1010

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 1324kb

input:

536780502 141579856

output:

7384733

result:

ok single line: '7384733'

Test #5:

score: 0
Accepted
time: 0ms
memory: 1288kb

input:

108493886 96306036

output:

42059094

result:

ok single line: '42059094'

Test #6:

score: 0
Accepted
time: 0ms
memory: 1320kb

input:

376650637 614573517

output:

237922880

result:

ok single line: '237922880'

Test #7:

score: 0
Accepted
time: 0ms
memory: 1272kb

input:

359617991 796927336

output:

437309345

result:

ok single line: '437309345'

Test #8:

score: 0
Accepted
time: 0ms
memory: 1308kb

input:

414483268 377437212

output:

170195579

result:

ok single line: '170195579'

Test #9:

score: 0
Accepted
time: 0ms
memory: 1288kb

input:

264989209 721686150

output:

456696941

result:

ok single line: '456696941'

Test #10:

score: 0
Accepted
time: 0ms
memory: 1240kb

input:

535692831 577823164

output:

42130333

result:

ok single line: '42130333'

Test #11:

score: 0
Accepted
time: 0ms
memory: 1300kb

input:

976420008 290057285

output:

45952285

result:

ok single line: '45952285'

Test #12:

score: 0
Accepted
time: 0ms
memory: 1288kb

input:

658562524 270258804

output:

105618175

result:

ok single line: '105618175'

Test #13:

score: 0
Accepted
time: 0ms
memory: 1316kb

input:

754831094 581446183

output:

204030637

result:

ok single line: '204030637'

Test #14:

score: 0
Accepted
time: 0ms
memory: 1236kb

input:

536870913 1

output:

59

result:

ok single line: '59'