#include <bits/stdc++.h>
using namespace std;
string a[30], b[30];
int n;
bool check()
{
for (int i = 0; i < n - 1; i++)
{
if (a[i].back() > '2' && b[i].back() > '2') return false;
if (a[i].back() < '3' && b[i].back() < '3') return false;
}
if (a[n - 1].back() < '3' || b[n - 1].back() > '2') return false;
return true;
}
int main()
{
int cass;
for (cin >> cass; cass; cass--)
{
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
cout << (check() ? "YES" : "NO") << "\n";
}
return 0;
}
View Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int cass;
for (cin >> cass; cass; cass--)
{
ll n, m;
cin >> n >> m;
if (n == 1)
{
cout << (m == 1 ? "2" : "1") << endl;
continue;
}
ll sum = 1;
while (n--) sum <<= 1;
cout << sum - (m ? 1 : 0) << endl;
}
return 0;
}
View Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[50];
int main()
{
a[0] = 1;
for (int i = 1; i <= 30; i++) a[i] = (i - 1) * (2 << (i - 1)) + 2;
int cass, k;
for (cin >> cass; cass; cass--)
{
cin >> k;
for (int i = 0; i <= 30; i++)
{
if (a[i] >= k)
{
cout << i << endl;
break;
}
}
}
return 0;
}
View Code