• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
nannandbk
博客园    首页    新随笔    联系   管理    订阅  订阅
2024 江西省赛 ACGHJK

2024 江西省赛 ACGHJK

A. Maliang Learning Painting

思路:签到,加起来就行了。

// AC one more times
// nndbk
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
    ll a,b,c; cin>>a>>b>>c;
    cout<<a+b+c<<"\n";


    return 0;
}

C. Liar

思路:先看当前的和sum和正确的和s,如果是一样的那么最多所有人都是真话。如果sum>s,那么大了,要变小,由于\(-10^4\le a_i\le10^4\)。为了变的次数尽量的少,我们肯定把大的变小会更优。否则把小的变大,直到第一个能跨变的地方(原来sum<s,变到sum>=s)。

// AC one more times
// nndbk
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
ll a[N];
int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
  

    ll n,s; cin>>n>>s;
    ll sum = 0;
    for(int i = 1;i <= n; i++)
    {
        ll x; cin>>x;
        a[i] = x;
        sum += x;
    }
    if(sum == s)cout<<n<<"\n";
    else{
        ll cnt = 0;
        sort(a+1,a+1+n);
        if(sum > s)
        {
            for(int i = n;i >= 1; i--)
            {
                sum -= a[i];
                sum += 1e4;
                cnt++;
                if(sum >= s)
                    break;
            }
        }else{
            for(int i = 1;i <= n; i++)
            {
                sum -= a[i];
                sum += (-1e4);
                cnt++;
                if(sum <= s)
                    break;
            }
        }
        cout<<n-cnt<<"\n";   
    }
    return 0;
}

G. Multiples of 5

思路:因为是11进制,很神奇的就是,它的任意次幂的最后一位都是1,我们只需要看有多少个1然后判断就行了。

// AC one more times
// nndbk
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
    int t; cin>>t;
    while(t--)
    {
        int n; cin>>n;
        ll ans = 0;
        for(int i = 1;i <= n; i++)
        {
            ll a; char b; cin>>a>>b;
            ll t;
            if(b != 'A')t = b-'0';
            else t = 10;
            // cout<<"t = "<<t<<"\n";
            ans += a*t;
        }
        // cout<<ans<<"\n";

        cout<<(ans%5==0?"Yes\n":"No\n");
    }


    return 0;
}

H.Convolution

// AC one more times
// nndbk
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e3 + 10;

ll I[N][N];
ll s[N][N];
int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
    int n,m,k,l; cin>>n>>m>>k>>l;

    for(int i = 1;i <= n; i++)
        for(int j = 1;j <= m; j++)
            cin>>I[i][j];

    for(int i = 1;i <= n; i++)
    {
        for(int j = 1;j <= m; j++)
        {
            s[i][j] = s[i-1][j]+s[i][j-1]-s[i-1][j-1]+I[i][j];
        }
    }

    ll ans = 0;

    for(int i = 1;i <= k; i++)
    {
        for(int j = 1;j <= l; j++)
        {
            int x1 = i,y1 = j;
            int x2 = x1 + n - k,y2 = y1 + m - l;
            ll t = s[x2][y2] - s[x1-1][y2] - s[x2][y1-1] + s[x1-1][y1-1];
            // cout<<t<<" ";
            if(t >= 0)ans += t;
            else ans -= t;

        }
        // cout<<"\n";
    }

    cout<<ans<<"\n";
    return 0;
}

J.Magic Mahjong

思路:考的读题,模拟即可。

// AC one more times
// nndbk
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 10;

int cntp[N],cnts[N],cntm[N],cntz[N];

int main()
{
    ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
  
    int t; cin>>t;
    while(t--)
    {
        memset(cntp,0,sizeof(cntp));
        memset(cnts,0,sizeof(cnts));
        memset(cntm,0,sizeof(cntm));
        memset(cntz,0,sizeof(cntz));

        string str; cin>>str;
        str = "?" + str;
        int idx = 1;
        vector<int>p,s,m,z;
        while(idx <= 28)
        {
            char op = str[idx+1];
            // cout<<"op = "<<op<<"\n";
            if(op == 'p')
                p.push_back(str[idx]-'0');
            else if(op == 's')
                s.push_back(str[idx]-'0');
            else if(op == 'm')
                m.push_back(str[idx]-'0');
            else if(op == 'z')
                z.push_back(str[idx]-'0');
            idx += 2;
        }


        for(auto x : p)
            cntp[x]++;
        for(auto x : s)
            cnts[x]++;
        for(auto x : m)
            cntm[x]++;
        for(auto x : z)
            cntz[x]++;

        // //p
        // for(int i = 1;i <= 9; i++)
        //     cout<<cntp[i]<<" ";
        // cout<<"\n";
        // //s
        // for(int i = 1;i <= 9; i++)
        //     cout<<cnts[i]<<" ";
        // cout<<"\n";
        // //m
        // for(int i = 1;i <= 9; i++)
        //     cout<<cntm[i]<<" ";
        // cout<<"\n";
        // //z
        // for(int i = 1;i <= 9; i++)
        //      cout<<cntz[i]<<" ";
        // cout<<"\n";


        //Thirteen Orphans
        bool ok = true,other = false;
        for(int i = 1 ; i <= 7; i++)
        {
            if(cntz[i] == 0){
                ok = false;
                break;
            }
            if(cntz[i] >= 2)other = true;
        }


        if(cntp[1] == 0 || cntp[9] == 0 || cnts[1] == 0 || cnts[9] == 0 ||  cntm[1] == 0  || cntm[9] == 0)
            ok = false;

        if(cntp[1] >= 2 || cntp[9] >= 2 || cnts[1] >= 2 || cnts[9] >= 2 ||  cntm[1] >= 2  || cntm[9] >= 2)
            other = true;


        if(ok && other)
        {
            cout<<"Thirteen Orphans\n";
            continue;
        }

        //7 Pairs

        int pair = 0;
        //p
        for(int i = 1;i <= 9; i++)
            pair += (cntp[i] >= 2);
        //s
        for(int i = 1;i <= 9; i++)
            pair += (cnts[i] >= 2);
        //m
        for(int i = 1;i <= 9; i++)
            pair += (cntm[i] >= 2);
        //z
        for(int i = 1;i <= 9; i++)
            pair += (cntz[i] >= 2);

        if(pair >= 7)
            cout<<"7 Pairs\n";
        else cout<<"Otherwise\n";
    }

    return 0;
}

K. Magic Tree

其实每次到一个路口都有2中选择,答案就是\(2^{n-1}\)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353;

int main(){
	int m;cin >> m;
	ll ant = 1;
	for(int i = 0;i < m - 1;i++){
		ant = (ant * 2) % MOD;
	}
	cout << ant;
	return 0;
}
posted on 2024-10-29 15:16  nannandbk  阅读(41)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3