답안 #223465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223465 2020-04-15T09:39:23 Z brcode 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
#include "cmp.h"

using namespace std;
int power[10];
int arr[8] = {0,5000,10000,15000,20000,25000,30000};
void remember(int n) {
    power[0] = 1;
    for(int i=1;i<=6;i++){
        power[i] = power[i-1]*4;
    }
    
    for (int i = 5; i >=0 ;i--){
        ////cout<<((n >> (i * 2))*power[i])<<endl;
        bit_set(((n >> (i * 2))*power[i])+arr[5-i])= true;
    }
}
int compare(int n){
    int l = 0;
    int r = 5;
    int ans =-1;
    while(l<=r){
        int mid = (l+r)/2;
        //cout<<mid<<" "<<check[((n >> (mid * 2))*power[mid])+arr[5-mid]]<<endl;
        if(bit_get(((n >> (mid * 2))*power[mid])+arr[5-mid])){
            ans = mid;
            r=mid-1;
            
        }else{
            l=mid+1;
        }
    }
    if(ans == -1){
        return 1;
    }
    if(ans == 0){
       
        return 0;
    }
    
    l=0;
    r=3;
    int dig = ((n >> ((ans-1) * 2))*power[(ans-1)])-((n >> ((ans) * 2))*power[(ans)]);
    dig/=(power[ans-1]);
    
    bool seen = false;
    for(int i=0;i<3;i++){
        if(i==dig){
            seen=true;
            continue;
            
        }
        ////cout<<<<endl;
        if(i==2 && !seen){
            return 1;
        }
        if(bit_get(((n >> ((ans) * 2))*power[(ans)])+(i*power[ans-1])+arr[5-(ans-1)])){
            if(seen){
                return -1;
            }else{
                return 1;
            }
        }
    }
    return -1;
    
}
int main(){
    //remember(4095);
    ////cout<<compare(4095)<<endl;
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:16:16: error: invalid use of 'void'
         bit_set(((n >> (i * 2))*power[i])+arr[5-i])= true;
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~