Skip to content

Commit

Permalink
Merge pull request #131 from 33hm/main
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
aman-raza authored Oct 2, 2021
2 parents d77cb2d + 75f6ebe commit 1d8cf27
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 0 deletions.
52 changes: 52 additions & 0 deletions CPP/A_Leading_1s.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma GCC optimize ("trapv")
#include <bits/stdc++.h>
#include<algorithm>
#include <vector>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cstdlib>
#include<sstream>
#include <string.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first
#define ss second
#define pp pair<ll,ll>
#define ll long long
#define ld long double
#define endl "\n"

const ll mod=1e9+7;
void solve()
{
ll n, a=0,b=0,m=1, c=-1,k=0, i=0, j=0, l=1e9+5;
string s,p, q;
cin>>n;
vector<ll>v;
while(n){
v.pb(n%10);
n/=10;
}
reverse(all(v));
rep(i,0,v.size()){
if(v[i]=='1') k++;
else k+=(v.size()-1-i)*10;
}
cout<<k;
}
int main()
{
ios_base::sync_with_stdio(false);
cin. tie(0);cout. tie(0);
ll t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
106 changes: 106 additions & 0 deletions CPP/Alice_vs_Bob_Faceoff.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#pragma GCC optimize ("trapv")
#include <bits/stdc++.h>
#include<algorithm>
#include <vector>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cstdlib>
#include<sstream>
#include <string.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first
#define ss second
#define pp pair<ll,ll>
#define ll long long
#define ld long double
#define endl "\n"

const ll mod=1e9+7;
void solve()
{
ll n, a=0,b=0,m=1, c=-1,k=0, i=0, j=0, l=1e9+5;
string s,p, q;
// map<ll,ll>mp;
// mp[1]=0;
// mp[2]=1;
// rep(i,3,1e5+1){
// if(i%2) {
// if(mp[i-1]==0) mp[i]=1;
// else mp[i]=0;
// }
// else{
// a=2;j=0;
// while(a<=i){
// if(i%a==0 && mp[i/a]==1){
// j=1;mp[i]=0;break;
// }
// a*=2;
// }
// if(!j) mp[i]=1;
// }
// }

cin>>a;
rep(i,0,a){
cin>>n;
if(n==1) cout<<"Alice"<<endl;
else{
if(n%2){
n--;
b=0;
while(n){
c=0;
while(n%2==0) {
n/=2;c++;
}
n--;
if(c>=2) b++;
}
if(b>=2) cout<<"Bob"<<endl;
else{
if(b==0) cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
}
else{
b=0;
while(n){
c=0;
while(n%2==0) {
n/=2;c++;
}
n--;
if(c>=2) b++;
}
if(b>=2) cout<<"Alice"<<endl;
else{
if(b==0) cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
}
}
// if(mp[a]==0) cout<<"Alice"<<endl;
// else cout<<"Bob"<<endl;
}
// if(n==2 || n==5 || n==6 || n==9 || n==11 || n==13 || n==14 || n==17 || n==19)
// cout<<"Bob"<<endl;
// else cout<<"Alice"<<endl;
// for(int i=1;i<1e6;i++) cout<<i<<" ";
}
int main()
{
ios_base::sync_with_stdio(false);
cin. tie(0);cout. tie(0);
ll t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}

0 comments on commit 1d8cf27

Please sign in to comment.