제출 #411548

#제출 시각아이디문제언어결과실행 시간메모리
411548LouayFarah앵무새 (IOI11_parrots)C++14
34 / 100
4 ms1032 KiB
#include "bits/stdc++.h" #include "encoder.h" using namespace std; #define pb push_back vector<int> primes; void send(int a); void init_primes() { primes.resize(0); int nb = 2; while((int)primes.size()<32) { if(nb==2) primes.pb(nb); else { bool flag = true; for(int i = 2; i*i<=nb; i++) { if(nb%i==0) { flag = false; break; } } if(flag) primes.pb(nb); } nb++; } } void encode(int n, int m[]) { init_primes(); for(int i = 0; i<n; i++) { if(m[i]==0) { send(65535-i); continue; } string nb = bitset<8>(m[i]).to_string(); for(int pos = 1; pos<=8; pos++) { if(nb[8-pos]=='1') { send(primes[8+i]*(primes[pos-1])); } } } }
#include "bits/stdc++.h" #include "decoder.h" using namespace std; #define pb push_back vector<int> primes; void output(int b); void init_primes() { primes.resize(0); int nb = 2; while((int)primes.size()<32) { if(nb==2) primes.pb(nb); else { bool flag = true; for(int i = 2; i*i<=nb; i++) { if(nb%i==0) { flag = false; break; } } if(flag) primes.pb(nb); } nb++; } } void decode(int n, int l, int x[]) { init_primes(); for(int i = 0; i<n; i++) { int elt = 0; for(int j = 0; j<l; j++) { if(x[j]%primes[8+i]==0) { for(int k = 0; k<8; k++) { if(primes[k] == x[j]/primes[8+i]) { int cnt = k; int temp = 1; while(cnt--) temp*=2; elt+=temp; } } } } output(elt); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...