Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Codeforces Round 671 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions Codeforces/#671 (Div. 2)/A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
author: blair_
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename Arg1>
void prn(bool space, Arg1&& arg1)
{ cout<<arg1; if(space) cout<<" "; else cout<<"\n"; }
template <typename Arg1, typename... Args>
void prn(bool space, Arg1&& arg1, Args&&... args)
{ prn(space, arg1); prn(space, args...); }

ll mulmod(ll a,ll b,ll mod)
{ ll res=0; a=a%mod;
while(b>0)
{ if(b%2==1) res=(res+a)%mod;
a=(a*2)%mod; b/=2; }
return res % mod; }

ll powmod(ll x,ll y,ll p)
{ ll res=1; x=x%p;
while(y>0)
{ if (y&1) res=(res*x)%p;
y=y>>1; x=(x*x)%p; }
return res; }

ll log(ll n, ll b)
{ ll c=0;
while(n>(b-1))
{ c++; n/=b; } return c; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define vpl vector<pl>
#define vb vector<bool>
#define vl vector<ll>
#define vvl vector<vl>
#define vs vector<string>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

//check overflow
void solve()
{
ll i,j;
ll n;
cin>>n;
string s;
f0(i,n)
{
char c;
cin>>c;
s.pb(c);
}
if(n%2==1)
{
f0(i,n)
{
if((s[i]-'0')%2==1)
{
prn(0,1);
return;
}
i++;
}
prn(0,2);
return;
}
else
{
f0(i,n)
{
i++;
if((s[i]-'0')%2==0)
{
prn(0,2);
return;
}
}
prn(0,1);
return;
}
}

int main()
{

#ifdef Deeksha
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// solve();/*
ll t;
cin>>t;
for(ll tt=1;tt<=t;tt++)
{
// cout<<"Case #"<<tt<<": ";
solve();
}
//*/
}

116 changes: 116 additions & 0 deletions Codeforces/#671 (Div. 2)/B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
author: blair_
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename Arg1>
void prn(bool space, Arg1&& arg1)
{ cout<<arg1; if(space) cout<<" "; else cout<<"\n"; }
template <typename Arg1, typename... Args>
void prn(bool space, Arg1&& arg1, Args&&... args)
{ prn(space, arg1); prn(space, args...); }

ll mulmod(ll a,ll b,ll mod)
{ ll res=0; a=a%mod;
while(b>0)
{ if(b%2==1) res=(res+a)%mod;
a=(a*2)%mod; b/=2; }
return res % mod; }

ll powmod(ll x,ll y,ll p)
{ ll res=1; x=x%p;
while(y>0)
{ if (y&1) res=(res*x)%p;
y=y>>1; x=(x*x)%p; }
return res; }

ll log(ll n, ll b)
{ ll c=0;
while(n>(b-1))
{ c++; n/=b; } return c; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define vpl vector<pl>
#define vb vector<bool>
#define vl vector<ll>
#define vvl vector<vl>
#define vs vector<string>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

//check overflow
vl fib;

void solve()
{
ll i,j;
ll n;
cin>>n;
f0(i,fib.size())
{
if(fib[i]>n)
break;
}
prn(0,i);
return;
}

void pre()
{
fib.pb(1);
ll help = 2;
ll last = 1;
while(true)
{
ll ans = 2*last;
if(ans>1e18)
break;
if(help>1e9)
break;
ans+=help*help;
if(ans>1e18)
break;
if(ans+fib.back()>1e18)
break;
fib.pb(fib.back()+ans);
last=ans;
help*=2;
}
}

int main()
{

#ifdef Deeksha
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
pre();
// solve();/*
ll t;
cin>>t;
for(ll tt=1;tt<=t;tt++)
{
// cout<<"Case #"<<tt<<": ";
solve();
}
//*/
}

122 changes: 122 additions & 0 deletions Codeforces/#671 (Div. 2)/C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
author: blair_
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename Arg1>
void prn(bool space, Arg1&& arg1)
{ cout<<arg1; if(space) cout<<" "; else cout<<"\n"; }
template <typename Arg1, typename... Args>
void prn(bool space, Arg1&& arg1, Args&&... args)
{ prn(space, arg1); prn(space, args...); }

ll mulmod(ll a,ll b,ll mod)
{ ll res=0; a=a%mod;
while(b>0)
{ if(b%2==1) res=(res+a)%mod;
a=(a*2)%mod; b/=2; }
return res % mod; }

ll powmod(ll x,ll y,ll p)
{ ll res=1; x=x%p;
while(y>0)
{ if (y&1) res=(res*x)%p;
y=y>>1; x=(x*x)%p; }
return res; }

ll log(ll n, ll b)
{ ll c=0;
while(n>(b-1))
{ c++; n/=b; } return c; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define vpl vector<pl>
#define vb vector<bool>
#define vl vector<ll>
#define vvl vector<vl>
#define vs vector<string>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

//check overflow
void solve()
{
ll i,j;
ll n,k;
cin>>n>>k;
vl v(n);
ll same=0;
f0(i,n)
{
cin>>v[i];
if(v[i]==k)
same++;
}
if(same==n)
{
prn(0,0);
return;
}
if(same>0)
{
prn(0,1);
return;
}
ll sum=0;
f0(i,n)
{
sum+=v[i];
}
if(k==0)
{
if(sum==0)
prn(0,1);
else
prn(0,2);
return;
}
if(sum==k*n)
{
prn(0,1);
}
else
{
prn(0,2);
}
}

int main()
{

#ifdef Deeksha
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// solve();/*
ll t;
cin>>t;
for(ll tt=1;tt<=t;tt++)
{
// cout<<"Case #"<<tt<<": ";
solve();
}
//*/
}

Loading