Codeforces Round #786 (Div. 3)
A - Number Transformation
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
const int maxn = 1e2 + 10;
const int N = 6e6 + 100;
int dp[maxn][maxn];
int a[maxn][maxn];
int v[maxn];
void solve() {
int x,y;
cin>>x>>y;
if(y>=x){
if(y%x==0) {
cout<<1<< " "<<y/x<<endl;
return;
}
}
cout<<0<<" "<<0<<endl;
}
signed main() {
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
B - Dictionary
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
const int maxn = 1e2 + 10;
const int N = 6e6 + 100;
int dp[maxn][maxn];
int a[maxn][maxn];
int v[maxn];
void solve() {
string s;
cin>>s;
int sum=(s[0]-'a')*25;
sum+=s[1]-'a'+1;
if(s[1]-s[0]>0) sum-=1;
cout<<sum<<endl;
}
signed main() {
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
C - Infinite Replacement
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
const int maxn = 1e2 + 10;
const int N = 6e6 + 100;
int dp[maxn][maxn];
int a[maxn][maxn];
int v[maxn];
void solve() {
string s1,s2;
cin>>s1>>s2;
if(s2=="a") {
cout<<1<<endl;
return;
}
else{
for(int i=0;i<s2.size();i++){
if(s2[i]=='a') {
cout<<-1<<endl;
return;
}
}
}
int res=pow(2,s1.size());
cout<<res<<endl;
}
signed main() {
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}