首页 > 其他分享 >The 2024 CCPC National Invitational Contest (Northeast) ADEJ

The 2024 CCPC National Invitational Contest (Northeast) ADEJ

时间:2024-10-17 15:12:18浏览次数:1  
标签:Invitational Northeast const Contest int nullptr cin long tie

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;
}

标签:Invitational,Northeast,const,Contest,int,nullptr,cin,long,tie
From: https://www.cnblogs.com/nannandbk/p/18472363

相关文章

  • HIAST Collegiate Programming Contest 2024(非完全题解)
    C题HZY做的,等他补题解//#pragmaGCCoptimize("O3,unroll-loops")//#pragmaGCCtarget("avx2,bmi,bmi2,lzcnt,popcnt")////如果在不支持avx2的平台上将avx2换成avx或SSE之一#include<bits/stdc++.h>usingnamespacestd;#definexfirst#defineysecon......
  • AtCoder Beginner Contest 374 (A-E)
    AtCoderBeginnerContest374(A-E)比赛链接A-Takahashisan2#include<bits/stdc++.h>usingnamespacestd;usingi64=longlong;voidShowball(){strings;cin>>s;intn=s.size();cout<<(s.substr(n-3)=="san"......
  • 【ICPC】The 2021 ICPC Asia Shanghai Regional Programming Contest I
    SteadilyGrowingSteam#动态规划#背包#枚举题目描述AliceenjoysplayingacardgamecalledSteadilyGrowingSteam(asknownasSGS).Inthisgame,eachplayerwillplaydifferentrolesandhavedifferentskills.Playersgetcardsfromthedeckandu......
  • 【ICPC】The 2021 ICPC Asia Shenyang Regional Contest J
    LuggageLock#搜索#枚举题目描述EileenhasabigluggageandshewouldpickalotofthingsintheluggageeverytimewhenA-SOULgoesoutforashow.However,iftherearetoomanythingsintheluggage,the4-digitpasswordlockontheluggagewill......
  • 【ICPC】The 2021 ICPC Asia Shanghai Regional Programming Contest G
    EdgeGroups#树形结构#组合数学#树形dp题目描述Givenanundirectedconnectedgraphofnnnverticesandn......
  • 【ICPC】The 2021 ICPC Asia Shanghai Regional Programming Contest H
    LifeisaGame#最小生成树#重构树#图论#贪心题目描述Agoodproblemshouldhaveaconcisestatement.Youaregivenanarrayaaaoflength......
  • AtCoder Beginner Contest 375
    A-Seats#include<bits/stdc++.h>usingnamespacestd;usingi32=int32_t;usingi64=longlong;#defineintlonglongusingvi=vector<int>;usingpii=pair<int,int>;i32main(){ios::sync_with_stdio(false),cin.tie(null......
  • Panasonic Programming Contest 2024(AtCoder Beginner Contest 375)
    PanasonicProgrammingContest2024(AtCoderBeginnerContest375)\(A\)Seats\(AC\)基础字符串。点击查看代码intmain(){intn,ans=0,i;strings;cin>>n>>s;for(i=0;i<n;i++){ans+=(s[i]=='#'&&s[i......
  • AtCoder Beginner Contest 375
    省流版A.枚举所有子串判断即可B.模拟计算记录累加即可C.根据旋转的周期性对每个点旋转次数取模后暴力旋转即可D.枚举\(k\),考虑\(i,j\)的对数,写成数学表达式后维护个数和位置和即可E.背包问题,以前两个数组和为状态,考虑每个数移动到何处转移即可F.逆向,删边变加边,维护......
  • KEYENCE Programming Contest 2024(AtCoder Beginner Contest 374)E题
    六年级蒟蒻来题解了!!!题目大意:给定你一个n,表示有n个生产线,每一个生产线都有两种机器,第i个生产线第一件产品每天可以造Ai件零件但是得付出Pi元的代价,第二件产品每天可以生产Bi件物品但是得付出Qi元的代价,然后给你x元的预算问你所有流水线中的最小值的最大值是多少?思路:首先我们......