-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4a0b99
commit 26c6588
Showing
24 changed files
with
934 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
int solve() | ||
{ | ||
int n,ans=0; | ||
cin>>n; | ||
while(n>0) | ||
{ | ||
ans+=n/=5; | ||
} | ||
return ans; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout<<solve()<<"\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"YES"<<"\n" | ||
#define no cout<<"NO"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
bool solve() | ||
{ | ||
int a,b; | ||
cin>>a>>b; | ||
int t=2*(min(a,b))-max(a,b); | ||
if(t<0||t%3) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t; | ||
cin>>t; | ||
while(t--) | ||
{ | ||
solve()?yes:no; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
string solve() | ||
{ | ||
string s; | ||
int n,odd_count=0; | ||
vector<int>vec(26,0); | ||
cin>>s; | ||
n=s.size(); | ||
for(int i=0;i<n;i++) | ||
{ | ||
vec[s[i]-'A']++; | ||
} | ||
for(int i=0;i<26;i++) | ||
{ | ||
if(vec[i]&1) | ||
{ | ||
odd_count++; | ||
s[n/2]=(char)(i+'A'); | ||
vec[i]--; | ||
} | ||
} | ||
if(odd_count>1) | ||
{ | ||
return "NO SOLUTION"; | ||
} | ||
int j=0; | ||
for(int i=0;i<26;i++) | ||
{ | ||
while(vec[i]) | ||
{ | ||
s[j]=(char)(i+'A'); | ||
s[n-j-1]=(char)(i+'A');; | ||
vec[i]-=2; | ||
j++; | ||
} | ||
} | ||
return s; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout<<solve()<<"\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
void solve() | ||
{ | ||
int n,range,div,pos; | ||
cin>>n; | ||
range=pow(2,n); | ||
string s(n,'0'); | ||
cout<<s<<"\n"; | ||
for(int i=1;i<range;i++) | ||
{ | ||
div=1; | ||
pos=n-1; | ||
while(i%(div*2)==0) | ||
{ | ||
div*=2; | ||
pos--; | ||
} | ||
s[pos]=(s[pos]=='0')?'1':'0'; | ||
cout<<s<<"\n"; | ||
} | ||
return; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
solve(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
void solve(int n,int a,int b,int c) | ||
{ | ||
if(n==1) | ||
{ | ||
cout<<a<<" "<<c<<"\n"; | ||
return; | ||
} | ||
solve(n-1,a,c,b); | ||
cout<<a<<" "<<c<<"\n"; | ||
solve(n-1,b,a,c); | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int n; | ||
cin>>n; | ||
cout<<pow(2,n)-1<<"\n"; | ||
solve(n,1,2,3); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
void solve() | ||
{ | ||
int n; | ||
cin>>n; | ||
while(n!=1) | ||
{ | ||
cout<<n<<" "; | ||
if(n&1) | ||
{ | ||
n=n*3+1; | ||
} | ||
else | ||
{ | ||
n/=2; | ||
} | ||
} | ||
cout<<n; | ||
return; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
solve(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
int solve() | ||
{ | ||
int n,temp; | ||
cin>>n; | ||
vector<bool>vec(n,false); | ||
for(int i=0;i<n-1;i++) | ||
{ | ||
cin>>temp; | ||
vec[temp-1]=true; | ||
} | ||
for(int i=0;i<n;i++) | ||
{ | ||
if(!vec[i]) | ||
{ | ||
return i+1; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout<<solve()<<"\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
int solve() | ||
{ | ||
int n,curr,ans=0; | ||
string s; | ||
cin>>s; | ||
n=s.size(); | ||
int i=0; | ||
while(i<n) | ||
{ | ||
curr=1; | ||
while(i<n-1&&s[i]==s[i+1]) | ||
{ | ||
curr++; | ||
i++; | ||
} | ||
i++; | ||
ans=max(ans,curr); | ||
} | ||
return ans; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout<<solve(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
int solve() | ||
{ | ||
int n,curr,prev,ans=0; | ||
cin>>n; | ||
cin>>prev; | ||
for(int i=1;i<n;i++) | ||
{ | ||
cin>>curr; | ||
if(curr<prev) | ||
{ | ||
ans+=prev-curr; | ||
} | ||
else | ||
{ | ||
prev=curr; | ||
} | ||
} | ||
return ans; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout<<solve(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<bits/stdc++.h> | ||
#define yes cout<<"Yes"<<"\n" | ||
#define no cout<<"No"<<"\n" | ||
#define endl "\n" | ||
#define int long long | ||
using ll=long long; | ||
using namespace std; | ||
|
||
void solve() | ||
{ | ||
int n; | ||
cin>>n; | ||
if(n==1) | ||
{ | ||
cout<<1; | ||
return; | ||
} | ||
if(n<=3) | ||
{ | ||
cout<<"NO SOLUTION"; | ||
return; | ||
} | ||
for(int i=2;i<=n;i+=2) | ||
{ | ||
cout<<i<<" "; | ||
} | ||
for(int i=1;i<=n;i+=2) | ||
{ | ||
cout<<i<<" "; | ||
} | ||
return; | ||
} | ||
|
||
int32_t main() | ||
{ | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
solve(); | ||
return 0; | ||
} |
Oops, something went wrong.