feat: Add solutions for Codeforces problems 2009 A, B, and C

This commit is contained in:
ShazidMahsrafi 2024-09-04 00:58:13 +06:00
parent 33957f1ef8
commit 3ea2193127
4 changed files with 141 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define dbg(...)
#else
#include "Assets/debug.h"
#endif
#define int long long
#define ll long long
#define endl '\n'
#define ff first
#define ss second
#define ins insert
#define pb push_back
#define ppb pop_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rrep(i,a,b) for(int i=a; i>=b; --i)
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
ll pow(ll x,ll y,ll m=1e9+7) {ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
void solve()
{
int a,b;
cin>>a>>b;
cout<<b-a<<endl;
}
signed main()
{
FAST;
int TCS = 1;
cin >> TCS;
for (int TC = 1; TC <= TCS; ++TC)
{
// cout<<"Case "<<TC<<": ";
solve();
}
}

View File

@ -0,0 +1,52 @@
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define dbg(...)
#else
#include "Assets/debug.h"
#endif
#define int long long
#define ll long long
#define endl '\n'
#define ff first
#define ss second
#define ins insert
#define pb push_back
#define ppb pop_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rrep(i,a,b) for(int i=a; i>=b; --i)
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
ll pow(ll x,ll y,ll m=1e9+7) {ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
void solve()
{
int n;
cin>>n;
vector<int>v;
rep(i,0,n)
{
string s;
cin>>s;
for(int j=0; j<4; ++j)
{
if(s[j]=='#') v.pb(j+1);
}
}
for(int i=sz(v)-1; i>=0; --i) cout<<v[i]<<" ";
cout<<endl;
}
signed main()
{
FAST;
int TCS = 1;
cin >> TCS;
for (int TC = 1; TC <= TCS; ++TC)
{
// cout<<"Case "<<TC<<": ";
solve();
}
}

View File

@ -0,0 +1,45 @@
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define dbg(...)
#else
#include "Assets/debug.h"
#endif
#define int long long
#define ll long long
#define endl '\n'
#define ff first
#define ss second
#define ins insert
#define pb push_back
#define ppb pop_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rrep(i,a,b) for(int i=a; i>=b; --i)
#define yn(f) f? cout<<"YES\n":cout<<"NO\n"
#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr));
ll pow(ll x,ll y,ll m=1e9+7) {ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;}
void solve()
{
int x,y,k;
cin>>x>>y>>k;
int p=(x+k-1)/k;
int q=(y+k-1)/k;
int ans=2*max(p,q);
if(p>q) ans--;
cout<<ans<<endl;
}
signed main()
{
FAST;
int TCS = 1;
cin >> TCS;
for (int TC = 1; TC <= TCS; ++TC)
{
// cout<<"Case "<<TC<<": ";
solve();
}
}

View File

@ -404,6 +404,9 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
| 392 | 2000 C | Numeric String Template | [Question](https://codeforces.com/problemset/problem/2000/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2000%20C%20-%20Numeric%20String%20Template)
| 393 | 2007 A | Dora's Set | [Question](https://codeforces.com/problemset/problem/2007/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2007%20A%20-%20Dora's%20Set)
| 394 | 2007 B | Index and Maximum Value | [Question](https://codeforces.com/problemset/problem/2007/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2007%20B%20-%20Index%20and%20Maximum%20Value)
| 395 | 2009 A | Minimize! | [Question](https://codeforces.com/problemset/problem/2009/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2009%20A%20-%20Minimize!)
| 396 | 2009 B | osu!mania | [Question](https://codeforces.com/problemset/problem/2009/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2009%20B%20-%20osu!mania)
| 397 | 2009 C | The Legend of Freya the Frog | [Question](https://codeforces.com/problemset/problem/2009/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/2009%20C%20-%20The%20Legend%20of%20Freya%20the%20Frog)