QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623030#5721. Dividing by TwoRebukedCompile Error//C++14324b2024-10-09 09:41:342024-10-09 09:41:34

Judging History

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

  • [2024-10-09 09:41:34]
  • 评测
  • [2024-10-09 09:41:34]
  • 提交

answer

#include <iostream>
using namespace std;

int main() {
int a;
int b;
cin >> a >> b;
if(a == b) {
cout << "0";
} else if(b > a) {
cout << b-a;
} else {
if(a%b != 0) {
int count = 0;
while(a != b) {
++a;
a/=2;
if(a == b) {
++count;
break;
} else if(a<b) {
count += b-a;
break;
}
}
cout << count;
}
}

详细

answer.code: In function ‘int main()’:
answer.code:28:2: error: expected ‘}’ at end of input
   28 | }
      |  ^
answer.code:4:12: note: to match this ‘{’
    4 | int main() {
      |            ^