Skip to content

Commit

Permalink
Add solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 committed Nov 1, 2023
1 parent f566eb0 commit 1fce13d
Show file tree
Hide file tree
Showing 16 changed files with 879 additions and 0 deletions.
47 changes: 47 additions & 0 deletions 1714A. Everyone Loves to Sleep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

void solve() {

}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) solve();

return 0;
}
57 changes: 57 additions & 0 deletions 1720A - Burenka Plays with Fractions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

void solve() {
ll a, b, c, d;
cin >> a >> b >> c >> d;

ll x = a * d, y = b * c;

if (x == y) cout << "0\n";

else if (y != 0 and x % y == 0 or x != 0 and y % x == 0)
cout << "1\n";

else cout << "2\n";
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) solve();

return 0;
}
64 changes: 64 additions & 0 deletions 1726A - Mainak and Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

void solve() {
int n;
cin >> n;

vi arr(n);
for (int i = 0; i < n; i++) cin >> arr[i];

int ans = 0;

for (int i = 1; i <= n - 1; i++)
ans = max(ans, arr[i] - arr[0]);

for (int i = 0; i < n - 1; i++)
ans = max(ans, arr[i] - arr[i + 1]);

for (int i = 0; i <= n - 2; i++)
ans = max(ans, arr[n - 1] - arr[i]);

cout << ans << '\n';
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) solve();

return 0;
}
58 changes: 58 additions & 0 deletions 1732B. Ugu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

void solve() {
int n;
cin >> n;
str s;
cin >> s;

int cnt = 1;
for (int i = 1; i < n; i++) {
if (s[i - 1] != s[i]) cnt++;
}

if (s[0] == '1' || cnt == 1) cout << cnt - 1 << '\n';
else cout << cnt - 2 << '\n';
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) solve();

return 0;
}
59 changes: 59 additions & 0 deletions 1733B. Rule of League.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) {
int n, x, y;
cin >> n >> x >> y;

if (x > y) swap(x, y);

if (x || !y || (n - 1) % y) {
cout << -1 << '\n';
continue;
}

for (int k = 2; k <= n; k += y) {
for (int i = 1; i <= y; i++) cout << k << ' ';
}

cout << '\n';
}

return 0;
}
57 changes: 57 additions & 0 deletions 1735B. Tea with Tangerines.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using str = string;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<str>;
using vc = vector<char>;

#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back

const int mod = 998244353; // 1e9+7;

void solve() {
int n;
cin >> n;

vi a(n);
int ans = 0;
for (auto &i : a) {
cin >> i;
ans += (i - 1) / (2 * a[0] - 1);
}

cout << ans << '\n';
}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

int tc = 1;
cin >> tc;

while (tc--) solve();

return 0;
}
Loading

0 comments on commit 1fce13d

Please sign in to comment.