From 91e81d29df1b73b3c045db61094d60e26d216d85 Mon Sep 17 00:00:00 2001 From: "Paulo H. Lamounier" <53798700+Nanashii76@users.noreply.github.com> Date: Mon, 3 Jun 2024 10:50:20 -0300 Subject: [PATCH] cp tep problems --- TEP/vjudge/treino001/A.cpp | 12 +++++ TEP/vjudge/treino001/B.cpp | 21 +++++++++ TEP/vjudge/treino001/C.cpp | 20 +++++++++ TEP/vjudge/treino002/A.cpp | 5 +++ TEP/vjudge/treino004/A.cpp | 89 ++++++++++++++++++++++++++++++++++++++ TEP/vjudge/treino028/A.cpp | 13 ++++++ TEP/vjudge/treino034/A.cpp | 16 +++++++ TEP/vjudge/treino034/B.cpp | 18 ++++++++ TEP/vjudge/treino034/C.cpp | 36 +++++++++++++++ 9 files changed, 230 insertions(+) create mode 100644 TEP/vjudge/treino001/A.cpp create mode 100644 TEP/vjudge/treino001/B.cpp create mode 100644 TEP/vjudge/treino001/C.cpp create mode 100644 TEP/vjudge/treino002/A.cpp create mode 100644 TEP/vjudge/treino004/A.cpp create mode 100644 TEP/vjudge/treino028/A.cpp create mode 100644 TEP/vjudge/treino034/A.cpp create mode 100644 TEP/vjudge/treino034/B.cpp create mode 100644 TEP/vjudge/treino034/C.cpp diff --git a/TEP/vjudge/treino001/A.cpp b/TEP/vjudge/treino001/A.cpp new file mode 100644 index 0000000..2de3d87 --- /dev/null +++ b/TEP/vjudge/treino001/A.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; + +int main(){ + + int a,b,c,d; cin >> a >> b >> c >> d; + + cout << (a*d)-(b*c) << endl; + + return 0; + +} \ No newline at end of file diff --git a/TEP/vjudge/treino001/B.cpp b/TEP/vjudge/treino001/B.cpp new file mode 100644 index 0000000..3dc0fac --- /dev/null +++ b/TEP/vjudge/treino001/B.cpp @@ -0,0 +1,21 @@ +#include +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; +} \ No newline at end of file diff --git a/TEP/vjudge/treino001/C.cpp b/TEP/vjudge/treino001/C.cpp new file mode 100644 index 0000000..33c644a --- /dev/null +++ b/TEP/vjudge/treino001/C.cpp @@ -0,0 +1,20 @@ +#include +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; +} \ No newline at end of file diff --git a/TEP/vjudge/treino002/A.cpp b/TEP/vjudge/treino002/A.cpp new file mode 100644 index 0000000..dd7f9c5 --- /dev/null +++ b/TEP/vjudge/treino002/A.cpp @@ -0,0 +1,5 @@ +#include +using namespace std; + + +// NÃO CONSEGUI RESOLVER NENHUM PROBLEMA!!! \ No newline at end of file diff --git a/TEP/vjudge/treino004/A.cpp b/TEP/vjudge/treino004/A.cpp new file mode 100644 index 0000000..7911572 --- /dev/null +++ b/TEP/vjudge/treino004/A.cpp @@ -0,0 +1,89 @@ +#include +using namespace std; + + +void solve(vector &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 &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 &vec) { + + unordered_map 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 sizes; + while(n--) { + int t; cin >> t; + sizes.emplace_back(t); + } + + solve(sizes); + + return 0; +} \ No newline at end of file diff --git a/TEP/vjudge/treino028/A.cpp b/TEP/vjudge/treino028/A.cpp new file mode 100644 index 0000000..eb48277 --- /dev/null +++ b/TEP/vjudge/treino028/A.cpp @@ -0,0 +1,13 @@ +#include +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; + +} \ No newline at end of file diff --git a/TEP/vjudge/treino034/A.cpp b/TEP/vjudge/treino034/A.cpp new file mode 100644 index 0000000..285e746 --- /dev/null +++ b/TEP/vjudge/treino034/A.cpp @@ -0,0 +1,16 @@ +#include +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; + +} \ No newline at end of file diff --git a/TEP/vjudge/treino034/B.cpp b/TEP/vjudge/treino034/B.cpp new file mode 100644 index 0000000..8175fc7 --- /dev/null +++ b/TEP/vjudge/treino034/B.cpp @@ -0,0 +1,18 @@ +#include +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; + +} \ No newline at end of file diff --git a/TEP/vjudge/treino034/C.cpp b/TEP/vjudge/treino034/C.cpp new file mode 100644 index 0000000..2f056bd --- /dev/null +++ b/TEP/vjudge/treino034/C.cpp @@ -0,0 +1,36 @@ +#include +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 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; + + + +} \ No newline at end of file