-
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
f18bf45
commit 91e81d2
Showing
9 changed files
with
230 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,12 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int a,b,c,d; cin >> a >> b >> c >> d; | ||
|
||
cout << (a*d)-(b*c) << 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,21 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
|
||
int main(){ | ||
|
||
int n,x; cin >> n >> x; | ||
while(n--) { | ||
char ch; cin >> ch; | ||
if(x == 0 and ch == 'x') x = 0; | ||
else if(ch == 'o') x++; | ||
else | ||
x--; | ||
|
||
//cout << x << endl; | ||
} | ||
|
||
cout << x << 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,20 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
int main(){ | ||
|
||
ll r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2; | ||
|
||
if(r1 == r2 and c1 == c2) | ||
cout << 0 << endl; | ||
else if(r1+c1 == r2+c2 or r1-c1 == r2-c2 or (abs(r1 - r2) + abs(c1-c2)) <= 3) | ||
cout << 1 << endl; | ||
else if((r1+r2+c1+c2) % 2 == 0) | ||
cout << 2 << endl; | ||
else | ||
cout << 3 << 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,5 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
|
||
// NÃO CONSEGUI RESOLVER NENHUM PROBLEMA!!! |
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,89 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
|
||
void solve(vector<int> &vec) { | ||
|
||
int cont = 0, l = 0, sum = 0; | ||
int ans = 360; | ||
|
||
while(cont < (int)vec.size()) { | ||
sum += vec[cont]; | ||
while(sum >= 180) { | ||
ans = min(ans,2*abs(sum-180)); | ||
sum -= vec[l]; | ||
l++; | ||
} | ||
ans = min(ans,2*abs(sum-180)); | ||
cont++; | ||
} | ||
|
||
cout << ans << endl; | ||
|
||
} | ||
|
||
|
||
/* Minhas outras 2 soluções | ||
void solve(vector<int> &vec) { | ||
if(!((int)vec.size()&1)) { | ||
cout << 0 << endl; | ||
return; | ||
} | ||
if((int)vec.size() == 1) { | ||
cout << vec[0] << endl; | ||
return; | ||
} | ||
int max = *max_element(vec.begin(),vec.end()); | ||
int count = 0; | ||
for(int i = 0; i < (int)vec.size(); ++i) | ||
count += min(vec[i],vec[i+1]); | ||
cout << abs(count-max) << endl; | ||
} | ||
void solve(vector<int> &vec) { | ||
unordered_map<int,int> pizza; | ||
for(const auto& x : vec) | ||
pizza[x]++; | ||
for(int i = 0; i < (int)vec.size(); ++i) { | ||
if(pizza.count(180-vec[i])) { | ||
pizza.erase(vec[i]); | ||
pizza.erase(180-vec[i]); | ||
} | ||
} | ||
if(pizza.size() == 0) { | ||
cout << 0 << endl; | ||
return; | ||
} else { | ||
sort(vec.begin(),vec.end()); | ||
int sum = 0; | ||
for(int i = 0; i < (int)vec.size()/2; ++i) | ||
sum += vec[i]; | ||
cout << abs(sum-vec[vec.size()-1]) << endl; | ||
return; | ||
} | ||
} | ||
*/ | ||
|
||
int main(){ | ||
|
||
int n; cin >> n; | ||
vector<int> sizes; | ||
while(n--) { | ||
int t; cin >> t; | ||
sizes.emplace_back(t); | ||
} | ||
|
||
solve(sizes); | ||
|
||
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,13 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
int main(){ | ||
|
||
ll n; cin >> n; | ||
ll count = ((n+1)*n)/2; | ||
|
||
cout << ( (count&1) ? "1" : "0" ) << 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,16 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int n; cin >> n; | ||
if(floor(1.08*n) < 206) | ||
cout << "Yay!" << endl; | ||
else if(floor(1.08*n) == 206) | ||
cout << "so-so" << endl; | ||
else if (floor(1.08*n) > 206) | ||
cout << ":(" << 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,18 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
typedef long long ll; | ||
|
||
int main(){ | ||
|
||
int n, index = 1; cin >> n; | ||
ll count = 0; | ||
for(int i = 1; count < n; ++i) { | ||
index = i; | ||
count += i; | ||
} | ||
|
||
cout << index << 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,36 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int nChoosek( int n, int k ) { | ||
if (k > n) return 0; | ||
if (k * 2 > n) k = n-k; | ||
if (k == 0) return 1; | ||
|
||
int result = n; | ||
for( int i = 2; i <= k; ++i ) { | ||
result *= (n-i+1); | ||
result /= i; | ||
} | ||
return result; | ||
} | ||
|
||
int main(){ | ||
|
||
int n, m, count = 0; cin >> n; | ||
m = n; | ||
set<int> s; | ||
while(n--) { | ||
int aux; cin >> aux; | ||
if(s.count(aux)) | ||
count++; | ||
s.insert(aux); | ||
} | ||
|
||
int i = nChoosek(m,2); | ||
cout << i << " " << count << endl; | ||
cout << i-count << endl; | ||
return 0; | ||
|
||
|
||
|
||
} |