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

The 2024 CCPC National Invitational Contest (Northeast) ADEJ

A.PaperWatering

思路:有两种类型的操作,对一个数开根号或平方。

平方没有什么问题,开根号由于是向下取整再平方就会产生不一样的数。

那么做法也很简单了。

对于一个数\(x\),\(k\)步,首先它能平方往后变\(k\)步,往前能变\(min(开根能变的步数,k)\)。我们去看往前开根的数,如果它的平方不等于它的下一个数,那么它的贡献就是\((k-x变成它的个数)\)。

注意,如果变成了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);
    ll x,k; cin>>x>>k;
    if(x == 1)
    {
        cout<<1<<"\n";
        return 0;
    }

    ll tmp = x;
    ll used = 0;

    ll ans = k;

    ll cnt = 0;
    while(x != 1)
    {
        
        cnt++;
        if(cnt < k && (ll)sqrt(x)*(ll)sqrt(x) != x && (ll)sqrt(x) != 1)
        {
            // cout<<"(ll)sqrt(x) = "<<(ll)sqrt(x)<<" k-cnt = "<<k-cnt<<"\n";
            ans += (k-cnt);
        }
        x = (ll)sqrt(x);
        // cout<<"x = "<<x<<"\n";
    }
    cout<<ans + min(cnt,k)+ 1ll<<"\n";
    return 0;
}

这题本身难度不大,但是写的时候还是出了问题。

一开始是认为找到第一个完全平方数就停止。其实并不是的,因为完全平方数开根之后不一定也是完全平方,所以需要看前面的所有数。

D.nIMgAME

思路:好好好,这题就充分体现了出题人的恶趣味了。一开始以为是正经博弈找规律。考虑他什么时候能赢?写了前几个之后发现,都不可能赢啊,他赢的条件实在是太难了。就想难不成永远都是lose?交一发,好好好过了。

// 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--)
    {
        ll n; cin>>n;
        cout<<"lose\n";
    }


    return 0;
}

E.Checksum

思路:考虑去枚举B有i个1。总的1的个数就是\(i+cnt(A中1的个数)\)。然后去check:\(C=i+cnt\)对应的二进制的低位k个1的个数\(D\)(如果大于k位就截掉,小于k位就补0),是否等于我们枚举的\(i\)。

// 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--)
    {
        ll n,k; cin>>n>>k;

        int cnt = 0;
        string s; cin>>s;
        for(int i = 0;i < s.size(); i++)
            cnt += (s[i]=='1');
       
        string ans = "99999999999999999999";
        for(int i = 0;i <= k; i++)
        {
            ll now = cnt+i;//十进制B
            string t = "";//二进制低k位B
            while(now && t.size() < k)
            {
                t += ((now&1) + '0');
                now >>= 1;
            }
            for(int j = t.size();j < k; j++)
                t += '0';
            reverse(t.begin(),t.end());
            int cnt1 = count(t.begin(),t.end(),'1');//二进制B中1的个数
            if(cnt1 == i)
                ans = min(ans,t);
        }

        if(ans == "99999999999999999999")cout<<"None\n";
        else cout<<ans<<"\n";

        
        
    }

    return 0;
}

J. Breakfast

签到不多说。

// 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);
    double n, m; cin>>n>>m;
    printf("%.2lf\n",0.6*n+m);


    return 0;
}

posted on 2024-10-17 15:15  nannandbk  阅读(40)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3