# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1212071 | doublepun | Coins (IOI17_coins) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
string contoBin(int n)
{
string ans = "";
for (int r = 0;r < 6;r++)
{
stringstream ss;
string pre;
ss << (n%2);
ss >> pre;
ans+=pre;
n = floor(n/2);
}
reverse(ans.begin(),ans.end());
return ans;
}
int find_coin(vector<int> b)
{
return ((b[0]*pow(2,5) + b[1]*pow(2,4) + b[2]*pow(2,3) + b[3]*pow(2,2) + b[4]*2 + b[5]));
}
vector<int> coin_flips(vector<int> &b, int c)
{
vector<int> fliped;
string code = contoBin(c);
for (int i = 0;i < 6;i++)
{
stringstream ss2;
int temp;
ss2 << code[i];
ss2 >> temp;
if (b[i] != temp){
b[i] = temp;
fliped.emplace_back(i);
}
}
if (fliped.size() == 0)
{
fliped.emplace_back(63);
}
return fliped;
}