-
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
08582fa
commit 125b8d7
Showing
6 changed files
with
147 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,17 @@ | ||
#include <bits/stdc++.h> | ||
|
||
int main(void) { | ||
|
||
int n, aux, sum = 0; | ||
|
||
std::cin >> n; | ||
|
||
for(int i = 0; i < n; ++i) { | ||
std::cin >> aux; | ||
if (aux > 10) | ||
sum += aux-10; | ||
} | ||
|
||
std::cout << sum << std::endl; | ||
|
||
} |
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,38 @@ | ||
#include <bits/stdc++.h> | ||
|
||
|
||
bool compare(std::vector<int> v, int n) { | ||
|
||
std::vector<int> s; | ||
for(int i = 1; i <= n; ++i) | ||
s.emplace_back(i); | ||
|
||
for(int i = 0; i < n; ++i) | ||
if(s[i] != v[i]) | ||
return false; | ||
|
||
return true; | ||
|
||
} | ||
|
||
|
||
|
||
int main() { | ||
|
||
int n, aux; | ||
std::cin >> n; | ||
|
||
std::vector<int> v; | ||
for(int i = 0; i < n; ++i) { | ||
std::cin >> aux; | ||
v.emplace_back(aux); | ||
} | ||
|
||
std::sort(v.begin(),v.end()); | ||
|
||
if (compare(v,n)) | ||
std::cout << "Yes" << std::endl; | ||
else | ||
std::cout << "No" << std::endl; | ||
|
||
} |
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 | ||
|
||
int main(void){ | ||
|
||
ll n, ans = 0; | ||
std::cin >> n; | ||
|
||
ll a[n]; | ||
// Don't need use a sort algorithm because of map | ||
std::map<ll, ll> m; | ||
for(int i = 0; i < n; ++i) { | ||
std::cin >> a[i]; | ||
m[a[i]]++; | ||
} | ||
|
||
for(int i = 0; i < n; ++i) | ||
ans+=n-i-1-(--m[a[i]]); | ||
|
||
std::cout << ans << std::endl; | ||
|
||
|
||
} |
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,27 @@ | ||
#include <bits/stdc++.h> | ||
|
||
|
||
int find_multiple (int a, int b, int c) { | ||
|
||
int cons = 1; | ||
|
||
while(c <= b) { | ||
c = cons*c; | ||
if (c >= a && c <= b) | ||
return c; | ||
else | ||
cons++; | ||
} | ||
|
||
return -1; | ||
|
||
} | ||
|
||
int main(void){ | ||
|
||
int a,b,c; | ||
std::cin >> a >> b >> c; | ||
|
||
std::cout << find_multiple(a,b,c) << std::endl; | ||
|
||
} |
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,28 @@ | ||
#include <bits/stdc++.h> | ||
|
||
typedef long long ll; | ||
|
||
int main() { | ||
|
||
ll n, k, sum = 0, aux; | ||
std::cin >> n; | ||
|
||
std::vector<ll> v; | ||
for(ll i = 0; i < n; ++i) { | ||
std::cin >> aux; | ||
v.emplace_back(aux); | ||
} | ||
|
||
std::cin >> k; | ||
|
||
for(ll i = 0; i < k; ++i) { | ||
sum += v[i%n]; | ||
if(sum > k) { | ||
aux = i; | ||
break; | ||
} | ||
} | ||
|
||
std::cout << aux+1 << std::endl; | ||
|
||
} |
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,14 @@ | ||
#include <bits/stdc++.h> | ||
|
||
int main(void) { | ||
|
||
int a,b; | ||
std::cin >> a >> b; | ||
|
||
if (abs(a-b) != 1 && abs(a-b) != 9) | ||
std::cout << "No" << std::endl; | ||
else | ||
std::cout << "Yes" << std::endl; | ||
|
||
|
||
} |