diff --git a/Codeforces/#671 (Div. 2)/A.cpp b/Codeforces/#671 (Div. 2)/A.cpp new file mode 100644 index 0000000..5aba33d --- /dev/null +++ b/Codeforces/#671 (Div. 2)/A.cpp @@ -0,0 +1,118 @@ +/* + author: blair_ +*/ + +#include +using namespace std; +typedef long long ll; + +template +void prn(bool space, Arg1&& arg1) +{ cout< +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=0;i--) +#define fn(i,s,d) for(i=s;i +#define vpl vector +#define vb vector +#define vl vector +#define vvl vector +#define vs vector +#define ff first +#define ss second +#define um unordered_map +#define dsort(v) sort(v); reverse(v); +#define maxpq(v) priority_queue +#define minpq(v) priority_queue,greater> + +//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 #"< +using namespace std; +typedef long long ll; + +template +void prn(bool space, Arg1&& arg1) +{ cout< +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=0;i--) +#define fn(i,s,d) for(i=s;i +#define vpl vector +#define vb vector +#define vl vector +#define vvl vector +#define vs vector +#define ff first +#define ss second +#define um unordered_map +#define dsort(v) sort(v); reverse(v); +#define maxpq(v) priority_queue +#define minpq(v) priority_queue,greater> + +//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 #"< +using namespace std; +typedef long long ll; + +template +void prn(bool space, Arg1&& arg1) +{ cout< +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=0;i--) +#define fn(i,s,d) for(i=s;i +#define vpl vector +#define vb vector +#define vl vector +#define vvl vector +#define vs vector +#define ff first +#define ss second +#define um unordered_map +#define dsort(v) sort(v); reverse(v); +#define maxpq(v) priority_queue +#define minpq(v) priority_queue,greater> + +//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 #"< +using namespace std; +typedef long long ll; + +template +void prn(bool space, Arg1&& arg1) +{ cout< +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=0;i--) +#define fn(i,s,d) for(i=s;i +#define vpl vector +#define vb vector +#define vl vector +#define vvl vector +#define vs vector +#define ff first +#define ss second +#define um unordered_map +#define dsort(v) sort(v); reverse(v); +#define maxpq(v) priority_queue +#define minpq(v) priority_queue,greater> + +//check overflow +void solve() +{ + ll i,j; + ll n; + cin>>n; + vl v(n); + f0(i,n) + cin>>v[i]; + sort(all(v)); + ll k=n-1; + k/=2; + prn(0,k); + vl ans(n); + ll count=0; + i=1; + j=0; + while(count +using namespace std; +typedef long long ll; + +template +void prn(bool space, Arg1&& arg1) +{ cout< +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=0;i--) +#define fn(i,s,d) for(i=s;i +#define vpl vector +#define vb vector +#define vl vector +#define vvl vector +#define vs vector +#define ff first +#define ss second +#define um unordered_map +#define dsort(v) sort(v); reverse(v); +#define maxpq(v) priority_queue +#define minpq(v) priority_queue,greater> + +//check overflow +void solve() +{ + ll i,j; + ll n; + cin>>n; + vl v(n); + f0(i,n) + cin>>v[i]; + if(n<3) + { + prn(0,0); + for(auto i:v) + prn(1,i); + prn(0,""); + return; + } + sort(all(v)); + + j=0; + vl ans(n); + for(i=1;ians[i]&&ans[i]ans[i]&&ans[i]