feat: Add solutions for Codeforces problems 1982A and 1982B
This commit is contained in:
parent
771ba7f813
commit
b0a4422e9b
45
Codes/1982 A - Soccer/1982A.cpp
Normal file
45
Codes/1982 A - Soccer/1982A.cpp
Normal 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 all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define yes cout << "YES" << endl
|
||||
#define no cout << "NO" << endl
|
||||
#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 pb push_back
|
||||
#define ppb pop_back
|
||||
#define ins insert
|
||||
#define ff first
|
||||
#define ss second
|
||||
#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,c,d;
|
||||
cin>>a>>b>>c>>d;
|
||||
if(a>b && c<d || a<b && c>d)
|
||||
no;
|
||||
else
|
||||
yes;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
FAST;
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
54
Codes/1982 B - Collatz Conjecture/1982B.cpp
Normal file
54
Codes/1982 B - Collatz Conjecture/1982B.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#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 all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define yes cout << "YES" << endl
|
||||
#define no cout << "NO" << endl
|
||||
#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 pb push_back
|
||||
#define ppb pop_back
|
||||
#define ins insert
|
||||
#define ff first
|
||||
#define ss second
|
||||
#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;
|
||||
while(k)
|
||||
{
|
||||
int r=x%y;
|
||||
x += min(k,y-r);
|
||||
k -= min(k,y-r);
|
||||
while(x%y==0) x /= y;
|
||||
if(x==1)
|
||||
{
|
||||
cout<<k%(y-1)+1<<endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout<<x<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
FAST;
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
26
Readme.md
26
Readme.md
@ -342,18 +342,20 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
||||
| 330 | 1981 A | Turtle and Piggy Are Playing a Game | [Question](https://codeforces.com/problemset/problem/1981/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1981%20A%20-%20Turtle%20and%20Piggy%20Are%20Playing%20a%20Game)
|
||||
| 331 | 1981 B | Turtle and an Infinite Sequence | [Question](https://codeforces.com/problemset/problem/1981/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1981%20B%20-%20Turtle%20and%20an%20Infinite%20Sequence)
|
||||
| 332 | 1981 C | Turtle and an Incomplete Sequence | [Question](https://codeforces.com/problemset/problem/1981/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1981%20C%20-%20Turtle%20and%20an%20Incomplete%20Sequence)
|
||||
| 333 | 1985 A | Creating Words | [Question](https://codeforces.com/problemset/problem/1985/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20A%20-%20Creating%20Words)
|
||||
| 334 | 1985 B | Maximum Multiple Sum | [Question](https://codeforces.com/problemset/problem/1985/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20B%20-%20Maximum%20Multiple%20Sum)
|
||||
| 335 | 1985 C | Good Prefixes | [Question](https://codeforces.com/problemset/problem/1985/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20C%20-%20Good%20Prefixes)
|
||||
| 336 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
||||
| 337 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
||||
| 338 | 1985 F | Final Boss | [Question](https://codeforces.com/problemset/problem/1985/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20F%20-%20Final%20Boss)
|
||||
| 339 | 1985 G | D-Function | [Question](https://codeforces.com/problemset/problem/1985/G) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20G%20-%20D-Function)
|
||||
| 340 | 1986 A | X Axis | [Question](https://codeforces.com/problemset/problem/1986/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20A%20-%20X%20Axis)
|
||||
| 341 | 1986 B | Matrix Stabilization | [Question](https://codeforces.com/problemset/problem/1986/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20B%20-%20Matrix%20Stabilization)
|
||||
| 342 | 1986 C | Update Queries | [Question](https://codeforces.com/problemset/problem/1986/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20C%20-%20Update%20Queries)
|
||||
| 343 | 1986 D | Mathematical Problem | [Question](https://codeforces.com/problemset/problem/1986/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20D%20-%20Mathematical%20Problem)
|
||||
| 344 | 1986 E | Beautiful Array | [Question](https://codeforces.com/problemset/problem/1986/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20E%20-%20Beautiful%20Array)
|
||||
| 333 | 1982 A | Soccer | [Question](https://codeforces.com/problemset/problem/1982/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1982%20A%20-%20Soccer)
|
||||
| 334 | 1982 B | Collatz Conjecture | [Question](https://codeforces.com/problemset/problem/1982/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1982%20B%20-%20Collatz%20Conjecture)
|
||||
| 335 | 1985 A | Creating Words | [Question](https://codeforces.com/problemset/problem/1985/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20A%20-%20Creating%20Words)
|
||||
| 336 | 1985 B | Maximum Multiple Sum | [Question](https://codeforces.com/problemset/problem/1985/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20B%20-%20Maximum%20Multiple%20Sum)
|
||||
| 337 | 1985 C | Good Prefixes | [Question](https://codeforces.com/problemset/problem/1985/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20C%20-%20Good%20Prefixes)
|
||||
| 338 | 1985 D | Manhattan Circle | [Question](https://codeforces.com/problemset/problem/1985/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20D%20-%20Manhattan%20Circle)
|
||||
| 339 | 1985 E | Secret Box | [Question](https://codeforces.com/problemset/problem/1985/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20E%20-%20Secret%20Box)
|
||||
| 340 | 1985 F | Final Boss | [Question](https://codeforces.com/problemset/problem/1985/F) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20F%20-%20Final%20Boss)
|
||||
| 341 | 1985 G | D-Function | [Question](https://codeforces.com/problemset/problem/1985/G) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1985%20G%20-%20D-Function)
|
||||
| 342 | 1986 A | X Axis | [Question](https://codeforces.com/problemset/problem/1986/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20A%20-%20X%20Axis)
|
||||
| 343 | 1986 B | Matrix Stabilization | [Question](https://codeforces.com/problemset/problem/1986/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20B%20-%20Matrix%20Stabilization)
|
||||
| 344 | 1986 C | Update Queries | [Question](https://codeforces.com/problemset/problem/1986/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20C%20-%20Update%20Queries)
|
||||
| 345 | 1986 D | Mathematical Problem | [Question](https://codeforces.com/problemset/problem/1986/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20D%20-%20Mathematical%20Problem)
|
||||
| 346 | 1986 E | Beautiful Array | [Question](https://codeforces.com/problemset/problem/1986/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1986%20E%20-%20Beautiful%20Array)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user