Skip to content

Commit 6461393

Browse files
committed
Warming up for the fcpc contest
1 parent 97c3919 commit 6461393

File tree

4 files changed

+202
-0
lines changed

4 files changed

+202
-0
lines changed

problemset/1374B.cpp

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
*** In The Name Of GOD ***
3+
author: AliBinary
4+
Email: AliGhanbariCs@gmail.com
5+
GitHub: https://github.com/AliBinary
6+
created: 21.11.2024 22:19:37
7+
*/
8+
9+
#include <bits/stdc++.h>
10+
using namespace std;
11+
12+
#define endl '\n'
13+
#define sep ' '
14+
typedef long long ll;
15+
typedef long double ld;
16+
typedef string str;
17+
18+
// pairs
19+
typedef pair<ll, ll> pll;
20+
typedef pair<int, int> pii;
21+
#define F first
22+
#define S second
23+
#define mp make_pair
24+
25+
#define tcT template <class T
26+
tcT > using V = vector<T>;
27+
28+
// vectors
29+
#define sz(x) int((x).size())
30+
#define bg(x) begin(x)
31+
#define all(x) bg(x), end(x)
32+
#define rall(x) x.rbegin(), x.rend()
33+
#define sor(x) sort(all(x));
34+
#define sor_(x) sort(rall(x));
35+
#define pb push_back
36+
#define eb emplace_back
37+
#define ft front()
38+
#define bk back()
39+
tcT > void remDup(vector<T> &v) { sort(all(v)), v.erase(unique(all(v)), end(v)); } // sort and remove duplicates
40+
#define cpresent(container, element) (find(all(container), element) != container.end()) // vector
41+
42+
// sets
43+
#define present(container, element) (container.find(element) != container.end()) // set/map
44+
#define lb lower_bound
45+
#define ub upper_bound
46+
tcT > int lwb(V<T> &a, const T &b) { return int(lb(all(a), b) - bg(a)); }
47+
tcT > int upb(V<T> &a, const T &b) { return int(ub(all(a), b) - bg(a)); }
48+
49+
// maps
50+
typedef map<int, int> mii;
51+
typedef map<str, int> msi;
52+
53+
// loops
54+
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
55+
#define F0R(i, b) FOR(i, 0, b)
56+
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); --i)
57+
#define R0F(i, b) ROF(i, 0, b)
58+
#define rep(n) FOR(_, 0, n)
59+
#define each(x, a) for (auto &x : a)
60+
#define tr(it, container) \
61+
for (typeof(container.begin()) it = container.begin(); it != container.end(); ++it)
62+
63+
// debug
64+
#define debug(x) cerr << #x << '=' << (x) << endl;
65+
#define debugp(x) cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
66+
#define debug2(x, y) cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}" << endl;
67+
#define debugv(v) \
68+
{ \
69+
cerr << #v << ": "; \
70+
for (auto x : v) \
71+
cerr << x << ' '; \
72+
cerr << endl; \
73+
}
74+
#define wall cout << "----------------------------------------\n";
75+
#define kill(x) \
76+
{ \
77+
cout << x << endl; \
78+
return; \
79+
}
80+
81+
// Etc...
82+
#define PI 3.14159265358979323846
83+
#define MOD 1000000007
84+
const int inf = std::numeric_limits<int>::max();
85+
const ll INF = std::numeric_limits<ll>::max();
86+
const ld epsilon = 1. / INF;
87+
bool cmp(pii &a, pii &b) { return (a.second < b.second); }
88+
89+
void solve()
90+
{
91+
ll n;
92+
cin >> n;
93+
int ans = 0;
94+
while (n != 1)
95+
{
96+
if (n % 3 != 0)
97+
kill(-1);
98+
ans++;
99+
if (n % 6 == 0)
100+
n /= 6;
101+
else
102+
n *= 2;
103+
}
104+
cout << ans << endl;
105+
}
106+
107+
int main()
108+
{
109+
ios_base::sync_with_stdio(false);
110+
cin.tie(NULL), cout.tie(NULL);
111+
112+
int t = 1;
113+
cin >> t;
114+
while (t--)
115+
{
116+
solve();
117+
}
118+
return 0;
119+
}
120+
121+
/* stuff you should look for
122+
* int overflow, array bounds
123+
* special cases (n=1?)
124+
* do smth instead of nothing and stay organized
125+
* WRITE STUFF DOWN
126+
* DON'T GET STUCK ON ONE APPROACH
127+
*/

problemset/1475B.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
const int N = 1e5 + 5;
6+
7+
void Main()
8+
{
9+
int n;
10+
cin >> n;
11+
if (n % 2020 <= n / 2020)
12+
cout << "YES";
13+
else
14+
cout << "NO";
15+
cout << endl;
16+
}
17+
18+
int main()
19+
{
20+
ios_base::sync_with_stdio(false);
21+
cin.tie(0), cout.tie(0);
22+
int t = 1;
23+
cin >> t;
24+
while (t--)
25+
Main();
26+
return 0;
27+
}

problemset/1985A.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
const int N = 1e5 + 5;
6+
7+
void Main()
8+
{
9+
string s1, s2;
10+
cin >> s1 >> s2;
11+
12+
swap(s1[0], s2[0]);
13+
cout << s1 << ' ' << s2 << '\n';
14+
}
15+
16+
int main()
17+
{
18+
ios_base::sync_with_stdio(false);
19+
cin.tie(0), cout.tie(0);
20+
int t = 1;
21+
cin >> t;
22+
while (t--)
23+
Main();
24+
return 0;
25+
}

problemset/2009A.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define ll long long
5+
const int N = 1e5 + 5;
6+
7+
void Main()
8+
{
9+
int a, b;
10+
cin >> a >> b;
11+
cout << b - a << endl;
12+
}
13+
14+
int main()
15+
{
16+
ios_base::sync_with_stdio(false);
17+
cin.tie(0), cout.tie(0);
18+
int t = 1;
19+
cin >> t;
20+
while (t--)
21+
Main();
22+
return 0;
23+
}

0 commit comments

Comments
 (0)