Skip to content

Commit

Permalink
cp tep problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanashii76 authored Jun 3, 2024
1 parent f18bf45 commit 91e81d2
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 0 deletions.
12 changes: 12 additions & 0 deletions TEP/vjudge/treino001/A.cpp
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;

}
21 changes: 21 additions & 0 deletions TEP/vjudge/treino001/B.cpp
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;
}
20 changes: 20 additions & 0 deletions TEP/vjudge/treino001/C.cpp
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;
}
5 changes: 5 additions & 0 deletions TEP/vjudge/treino002/A.cpp
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!!!
89 changes: 89 additions & 0 deletions TEP/vjudge/treino004/A.cpp
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;
}
13 changes: 13 additions & 0 deletions TEP/vjudge/treino028/A.cpp
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;

}
16 changes: 16 additions & 0 deletions TEP/vjudge/treino034/A.cpp
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;

}
18 changes: 18 additions & 0 deletions TEP/vjudge/treino034/B.cpp
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;

}
36 changes: 36 additions & 0 deletions TEP/vjudge/treino034/C.cpp
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;



}

0 comments on commit 91e81d2

Please sign in to comment.