A. Seismic magnitude scales
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
long long a,b;
cin >> a >> b;
cout << (long long)pow(2, (a - b) * 5);
return 0;
}
B typo
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
string a,b;
cin >> a;
cin >> b;
int cnt = 0;
if(a==b){
cout << "Yes";
return 0;
}
for (int i = 0; i < a.size()-1;i++){
swap(a[i], a[i + 1]);
if(a==b){
cout << "Yes";
return 0;
}
swap(a[i], a[i + 1]);
}
cout << "No";
return 0;
}
C Select Mul
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
string ss;
long long a[100], x = 0, y = 0, ma = 0;
int cmp(int a, int b) {
return a > b;
}
int main() {
cin >> ss;
int n = ss.size();
for (int i = 0; i < n; i++) {
a[i] = ss[i] - '0';
}
sort(a, a + n, cmp);
for (int i = 0; i < n; i++) {
if (x > y)
y = y * 10 + a[i];
else
x = x * 10 + a[i];
}
cout << x * y;
return 0;
}
D Online games
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int maxn = 2e5 + 10;
PII p[maxn << 1];
int n, ans[maxn];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
{
int a, b;
scanf("%d%d", &a, &b);
p[i * 2 - 1] = make_pair(a, 1);
p[i * 2] = make_pair(a + b, -1);
}
sort(p + 1, p + 2 * n + 1);
int cover = p[1].second;
for(int i = 2; i <= 2 * n; ++i)
{
ans[cover] += p[i].first - p[i - 1].first;
cover += p[i].second;
}
for(int i = 1; i <= n; ++i)
printf("%d ", ans[i]);
putchar('\n');
return 0;
}