# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1219118 | LM1 | Coins (IOI17_coins) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define fr(i,ii,iii) for(int i=ii;i<iii;i++)
//#include "coins.h"
using namespace std;
std::vector<int> coin_flips(std::vector<int> b, int c) {
std::vector<int> flips;
int l=16777216*(c-1);
int r=16777216*c;
int ss=0;
fr(i,0,30){
if(b[i]==1)ss+=(1<<i);
}
for(int i=29;i>=0;i--){
int x=(1<<i);
if((ss-x)>=l and (ss-x)<=r){
flips.pb(i);
break;
}
}
return flips;
}
int find_coin(std::vector<int> b) {
int ans=0;
fr(i,0,30){
if(b[i])ans+=(1<<i);
}
fr(i,0,64){
if(16777216*(i-1)<=ans and 16777216*(i)>=ans){
ans=i;
break;
}
}
return ans;
}