added 1979 a,b,c
This commit is contained in:
parent
10feba451c
commit
56a6f25363
33
Codes/1979 A - Guess the Maximum/1979A.cpp
Normal file
33
Codes/1979 A - Guess the Maximum/1979A.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
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(n);
|
||||
for(auto &i:v) cin>>i;
|
||||
int mx=INT_MAX;
|
||||
for(int i=1; i<n; ++i)
|
||||
{
|
||||
int x=v[i-1];
|
||||
int y=v[i];
|
||||
mx = min(mx, max(x,y));
|
||||
}
|
||||
cout<<mx-1<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
32
Codes/1979 B - XOR Sequences/1979B.cpp
Normal file
32
Codes/1979 B - XOR Sequences/1979B.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
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;
|
||||
cin >> x >> y;
|
||||
int ans=0;
|
||||
while(true)
|
||||
{
|
||||
if((x^y)&1) break;
|
||||
ans++;
|
||||
x>>=1;
|
||||
y>>=1;
|
||||
}
|
||||
cout<<(1<<ans)<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
41
Codes/1979 C - Earning on Bets/1979C.cpp
Normal file
41
Codes/1979 C - Earning on Bets/1979C.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
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(n);
|
||||
int l=1;
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
cin>>v[i];
|
||||
l = lcm(l,v[i]);
|
||||
}
|
||||
int sum=0;
|
||||
for(auto x:v)
|
||||
sum += l/x;
|
||||
if(sum>=l)
|
||||
{
|
||||
cout<<-1<<endl;
|
||||
return;
|
||||
}
|
||||
for(auto x:v)
|
||||
cout<<l/x<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
signed main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false), cin.tie(nullptr);
|
||||
int TCS = 1;
|
||||
cin >> TCS;
|
||||
for (int TC = 1; TC <= TCS; ++TC)
|
||||
{
|
||||
// cout<<"Case "<<TC<<": ";
|
||||
solve();
|
||||
}
|
||||
}
|
17
Readme.md
17
Readme.md
@ -329,13 +329,16 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
||||
| 317 | 1976 A | Verify Password | [Question](https://codeforces.com/problemset/problem/1976/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1976%20A%20-%20Verify%20Password)
|
||||
| 318 | 1976 B | Increase Decrease Copy | [Question](https://codeforces.com/problemset/problem/1976/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1976%20B%20-%20Increase%20Decrease%20Copy)
|
||||
| 319 | 1977 A | Little Nikita | [Question](https://codeforces.com/problemset/problem/1977/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1977%20A%20-%20Little%20Nikita)
|
||||
| 320 | 1980 A | Problem Generator | [Question](https://codeforces.com/problemset/problem/1980/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20A%20-%20Problem%20Generator)
|
||||
| 321 | 1980 B | Choosing Cubes | [Question](https://codeforces.com/problemset/problem/1980/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20B%20-%20Choosing%20Cubes)
|
||||
| 322 | 1980 C | Sofia and the Lost Operations | [Question](https://codeforces.com/problemset/problem/1980/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20C%20-%20Sofia%20and%20the%20Lost%20Operations)
|
||||
| 323 | 1980 D | GCD-sequence | [Question](https://codeforces.com/problemset/problem/1980/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20D%20-%20GCD-sequence)
|
||||
| 324 | 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)
|
||||
| 325 | 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)
|
||||
| 326 | 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)
|
||||
| 320 | 1979 A | Guess the Maximum | [Question](https://codeforces.com/problemset/problem/1979/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1979%20A%20-%20Guess%20the%20Maximum)
|
||||
| 321 | 1979 B | XOR Sequences | [Question](https://codeforces.com/problemset/problem/1979/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1979%20B%20-%20XOR%20Sequences)
|
||||
| 322 | 1979 C | Earning on Bets | [Question](https://codeforces.com/problemset/problem/1979/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1979%20C%20-%20Earning%20on%20Bets)
|
||||
| 323 | 1980 A | Problem Generator | [Question](https://codeforces.com/problemset/problem/1980/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20A%20-%20Problem%20Generator)
|
||||
| 324 | 1980 B | Choosing Cubes | [Question](https://codeforces.com/problemset/problem/1980/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20B%20-%20Choosing%20Cubes)
|
||||
| 325 | 1980 C | Sofia and the Lost Operations | [Question](https://codeforces.com/problemset/problem/1980/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20C%20-%20Sofia%20and%20the%20Lost%20Operations)
|
||||
| 326 | 1980 D | GCD-sequence | [Question](https://codeforces.com/problemset/problem/1980/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1980%20D%20-%20GCD-sequence)
|
||||
| 327 | 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)
|
||||
| 328 | 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)
|
||||
| 329 | 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)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user