gym 103495
A
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
using ld = long double;
inline int read();
inline void write(int);
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define lowbit(x) ((x) & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define PII pair<int, int>
#define fi first
#define se second
#define mem(x, y) memset(x, y, sizeof(x))
#define endl '\n'
const double PI = acos(-1.0);
#define eps 1e-7
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define debug(x) cerr << #x << ": " << x << endl;
const int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int maxn = 1e6 + 5;
const int mod = 998244353;
const int N = 1011;
void solve()
{
int n;
cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
a[i] = s[s.length() - 1]-'0';
}
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
b[i] = s[s.length() - 1]-'0';
}
for (int i = 1; i <= n; i++)
{
if (i != n)
{
if (a[i] == 1 || a[i] == 2)
{
if (b[i] == 3 || b[i] == 4)
continue;
else
{
cout << "NO" << endl;
return;
}
}
else
{
if (b[i] == 1 || b[i] == 2)
continue;
else
{
cout << "NO" << endl;
return;
}
}
}
else
{
if((a[i]==3||a[i]==4)&&(b[i]==1||b[i]==2))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--)
solve();
return 0;
}
inline int read()
{
register int x = 0, f = 1;
register char ch = getchar();
while (!isdigit(ch))
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch ^ '0');
ch = getchar();
}
return x * f;
}
inline void write(int x)
{
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
return;
}
I
#include <bits/stdc++.h>
#include <queue>
#include <unordered_map>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define INF (1 << 29)
const int N = 1e5 + 5;
#define int long long
#define yes "Yes"
#define no "No"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const int mod = 998244353;
inline long long read()
{
long long w = 1;
long long q = 0;
char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9'))
ch = getchar();
if (ch == '-')
w = -1, ch = getchar();
while (ch >= '0' && ch <= '9')
q = q * 10 + ch - '0', ch = getchar();
return w * q;
}
ll ebs(ll x, ll y)
{
if (y == 0)
return 1;
else
{
ll dp = ebs(x, y / 2);
if (y % 2 == 0)
{
return ((dp % mod) * (dp % mod)) % mod;
}
else
{
return ((dp % mod) * (dp % mod) * (x % mod)) % mod;
}
}
}
ll gcd(ll a, ll b)
{
while (b ^= a ^= b ^= a %= b)
;
return a;
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b) * b;
}
const double eps = 1e-7;
const int maxn = 1e5;
void solve()
{
int m, n;
cin >> m >> n;
if (m == 1)
{
if (n == 0)
{
cout << 1 << endl;
}
else
{
cout << 2 << endl;
}
}
else if (n != 0)
{
cout << (ll)pow(2, m) - 1 << endl;
}
else
{
cout << (ll)pow(2, m) << endl;
}
}
signed main()
{
IOS;
int tcase = 1;
cin >> tcase;
while (tcase--)
{
solve();
}
return 0;
}
K
#include <bits/stdc++.h>
#include <queue>
#include <unordered_map>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define INF (1 << 29)
const int N = 1e5 + 5;
#define int long long
#define yes "Yes"
#define no "No"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const int mod = 998244353;
inline long long read()
{
long long w = 1;
long long q = 0;
char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9'))
ch = getchar();
if (ch == '-')
w = -1, ch = getchar();
while (ch >= '0' && ch <= '9')
q = q * 10 + ch - '0', ch = getchar();
return w * q;
}
ll ebs(ll x, ll y)
{
if (y == 0)
return 1;
else
{
ll dp = ebs(x, y / 2);
if (y % 2 == 0)
{
return ((dp % mod) * (dp % mod)) % mod;
}
else
{
return ((dp % mod) * (dp % mod) * (x % mod)) % mod;
}
}
}
ll gcd(ll a, ll b)
{
while (b ^= a ^= b ^= a %= b)
;
return a;
}
ll lcm(ll a, ll b)
{
return a / gcd(a, b) * b;
}
const double eps = 1e-7;
const int maxn = 1e5;
void solve()
{
int n;
cin >> n;
if (n == 1)
{
cout << 0 << endl;
}
else if (n == 2)
{
cout << 1 << endl;
}
else
{
int sum = 2;
int cnt = 2;
for (int i = 2;; i++)
{
if (n <= sum)
{
cout << i - 1 << endl;
return;
}
sum += i * cnt;
cnt *= 2;
}
}
}
signed main()
{
IOS;
int tcase = 1;
cin >> tcase;
while (tcase--)
{
solve();
}
return 0;
}