QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623023#5721. Dividing by TwoRebukedCompile Error//C++14318b2024-10-09 09:39:322024-10-09 09:39:33

Judging History

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

  • [2024-10-09 09:39:33]
  • 评测
  • [2024-10-09 09:39:32]
  • 提交

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;
}

Details

answer.code: In function ‘int main()’:
answer.code:26:2: error: expected ‘}’ at end of input
   26 | }
      |  ^
answer.code:13:14: note: to match this ‘{’
   13 | if(a%b != 0) {
      |              ^
answer.code:26:2: error: expected ‘}’ at end of input
   26 | }
      |  ^
answer.code:12:8: note: to match this ‘{’
   12 | } else {
      |        ^
answer.code:26:2: error: expected ‘}’ at end of input
   26 | }
      |  ^
answer.code:4:12: note: to match this ‘{’
    4 | int main() {
      |            ^