답안 #26784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26784 2017-07-05T16:00:14 Z baactree 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include "cmp.h"

void remember(int n) {
    bit_set(10240-n);
    n++;
    while(n<5000){
        bit_set(n);
        n+=n&(-n);
    }
}

int compare(int b) {
    if(bit_set(10240-b))
        return 0;
    int ret=0;
    b++;
    while(b){
        ret+=bit_set(b);
        b-=b&(-b);
    }    
    if(ret>0)
        return 1;
    return -1;
}

Compilation message

cmp.cpp: In function 'int compare(int)':
cmp.cpp:13:15: error: could not convert 'bit_set((10240 - b))' from 'void' to 'bool'
     if(bit_set(10240-b))
        ~~~~~~~^~~~~~~~~
cmp.cpp:18:12: error: invalid operands of types 'int' and 'void' to binary 'operator+'
         ret+=bit_set(b);
         ~~~^~~~~~~~~~~~
cmp.cpp:18:23: error:   in evaluation of 'operator+=(int, void)'
         ret+=bit_set(b);
                       ^