-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Coach-Academy/Rania154-patch-2
Add files via upload
- Loading branch information
Showing
10 changed files
with
410 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,23 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
int n; | ||
cin >> n; | ||
int c1 = (n/3) + (n%3 == 1); | ||
int c2 = (n/3) + (n%3 == 2); | ||
cout << c1 << " " <<c2 << endl; | ||
} | ||
|
||
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,33 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
int n; | ||
cin >> n; | ||
int o =0, e =0; | ||
for (int i = 0; i < 2*n; ++i) { | ||
int x ; | ||
cin >> x; | ||
if ( x%2) | ||
o++; | ||
else | ||
e++; | ||
} | ||
if ( e == o) | ||
cout << "Yes\n"; | ||
else | ||
cout << "No\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,54 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n; | ||
cin >> n; | ||
int winner = 0; | ||
int a[n][5]; | ||
for (int i = 0; i < n; ++i) { | ||
int cnt = 0; | ||
for (int j = 0; j < 5; ++j) { | ||
cin >> a[i][j]; | ||
if ( a[winner][j] > a[i][j]) | ||
cnt++; | ||
} | ||
if ( cnt >= 3 ) | ||
{ | ||
winner = i; | ||
} | ||
} | ||
for (int i = 0; i < n; ++i) { | ||
int cnt = 0; | ||
for (int j = 0; j < 5; ++j) { | ||
if ( a[winner][j] > a[i][j]) | ||
cnt++; | ||
} | ||
if ( cnt >= 3 ) | ||
{ | ||
winner = -1; | ||
break; | ||
} | ||
} | ||
if ( winner == -1) | ||
cout << -1 << endl; | ||
else | ||
cout << winner+1 << endl; | ||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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,46 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n,a,b; | ||
cin >> n >> a>> b; | ||
ll x = 1; | ||
if ( a == 1) | ||
{ | ||
if ( (n-1)%b == 0) | ||
cout << "Yes\n"; | ||
else | ||
cout << "No\n"; | ||
} | ||
else | ||
{ | ||
while (x <= n) | ||
{ | ||
int rem = n-x; | ||
if ( rem %b ==0) | ||
{ | ||
cout << "Yes\n"; | ||
return; | ||
} | ||
x *= a; | ||
} | ||
cout << "No\n"; | ||
} | ||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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,31 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n; | ||
cin >> n; | ||
ll sum =0; | ||
for (int i = 0,x; i < n; ++i) { | ||
cin >> x; | ||
sum += x; | ||
} | ||
ll rem = sum%n; | ||
cout << rem * ( n-rem) << endl; | ||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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 ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n; | ||
cin >> n; | ||
vector<int> v(n); | ||
for (int i = 0; i < n; ++i) { | ||
cin >> v[i]; | ||
} | ||
sort(v.begin(), v.end()); | ||
int ans =0; | ||
for (int i = 0; i < n; ++i) { | ||
int l = i; | ||
int r = std::upper_bound(v.begin(), v.end(), v[i]+5) - v.begin()-1; | ||
int len = (r- l +1 ); | ||
ans = max(ans , len); | ||
} | ||
cout << ans << endl; | ||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t=1; | ||
//cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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,47 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n , k; | ||
cin >> n >> k; | ||
string a,b; | ||
cin >> a >> b; | ||
int fa[30]={}, fb[30]={}; | ||
for (int i = 0; i < n; ++i) { | ||
fa [ a[i] - 'a']++; | ||
fb [ b[i] - 'a'] ++; | ||
} | ||
for (int i = 0; i < 26; ++i) { | ||
int dif = fa[i] - fb[i]; | ||
if ( dif < 0) | ||
{ | ||
cout << "No\n"; | ||
return; | ||
} | ||
if ( dif %k !=0) | ||
{ | ||
cout << "No\n"; | ||
return; | ||
} | ||
fa[i+1] += dif; | ||
} | ||
cout << "Yes\n"; | ||
|
||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t=1; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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,48 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n; | ||
while (true) | ||
{ | ||
cin >> n; | ||
if ( n == 0) | ||
break; | ||
deque<int> dq; | ||
for (int i = 1; i <= n; ++i) { | ||
dq.push_back(i); | ||
} | ||
cout << "Discarded cards:"; | ||
while (dq.size() > 1) | ||
{ | ||
|
||
cout << " " << dq.front(); | ||
dq.pop_front(); | ||
dq.push_back(dq.front()); | ||
dq.pop_front(); | ||
if ( dq.size() > 1) | ||
cout << ","; | ||
|
||
} | ||
cout << endl; | ||
cout << "Remaining card: " << dq.front() << endl; | ||
} | ||
|
||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t=1; | ||
// cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
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,47 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#define ll long long | ||
#define endl '\n' | ||
using namespace std; | ||
|
||
void doWork() | ||
{ | ||
int n; | ||
cin >> n; | ||
int f[25] = {}; | ||
for (int i = 0; i < n; ++i) { | ||
int x; | ||
cin >> x; | ||
for (int j = 0; j < 25; ++j) { | ||
if (x & ( 1 << j)) | ||
f[j]++; | ||
} | ||
} | ||
ll ans =0; | ||
for (int i = 0; i < n; ++i) { | ||
ll x =0; | ||
for (int j = 0; j < 25; ++j) { | ||
if ( f[j] ) | ||
{ | ||
f[j] -- ; | ||
x |= ( 1 << j); | ||
} | ||
} | ||
ans += x*x; | ||
} | ||
cout << ans << endl; | ||
|
||
} | ||
int main() { | ||
ios::sync_with_stdio(false); | ||
cout.tie(nullptr); | ||
cin.tie(nullptr); | ||
int t=1; | ||
// cin >> t; | ||
while (t--) | ||
{ | ||
doWork(); | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.