gym 103495

gym 103495

A

#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define int __int128
typedef unsigned long long ull;
using ld = long double;
inline int read();
inline void write(int);
#define inf 0x3f3f3f3f         // 0x7fffffff 2147483647
#define INF 0x3f3f3f3f3f3f3f3f // 0x7fffffffffffffff 9223372036854775807
#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);
    // cout << fixed;
    // cout.precision(18);
    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;
//"----------------------     code     --------------------------"
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;
//"----------------------     code     --------------------------"
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;
}
  • 15
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值