# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411547 | LouayFarah | Parrots (IOI11_parrots) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#include "encoder.h"
using namespace std;
#define pb push_back
vector<int> primes;
void send(int a);
void encode(int n, int m[])
{
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++;
}
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]));
}
}
}
}