Codeforces Beta Round #76 (Div. 2 Only) A : Restoring Password
問題概要
ビット列->数字の変換テーブルが与えられるので、それにしたがってビット列を変換する問題。
acceptされたコード
#include <cstdio> #include <cstdlib> #include <string> using namespace std; const int MAX_L = 80; const int N = 10; const int KEY_LENGTH = 8; int table[1<<N]; int main(){ char buf[MAX_L + 1]; scanf("%[^\n]%*c", buf); string key(buf); for(int i=0; i<N; i++){ scanf("%[^\n]%*c", buf); table[strtol(buf, NULL, 2)] = i; } for(int i=0; i<KEY_LENGTH; i++){ printf("%d", table[strtol(key.substr(i*N, N).c_str(), NULL, 2)]); } puts(""); return 0; }