首页 > 其他分享 >SMU 2024 winter round1

SMU 2024 winter round1

时间:2024-01-26 21:44:07浏览次数:25  
标签:winter int SMU hey long cin 2024 solve left

题目链接

A.

直接输出

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    cout<<"Good code is its own best documentation."<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

B.

直接输出

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    int x;cin>>x;
    cout<<"print("<<x<<")"<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

C.

if else 输出

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    int n;cin>>n;
    string x;cin>>x;
    //cout<<x<<'\n';
    int m,k;cin>>m>>k;
    if(k==n)cout<<"mei you mai "<<x<<" de"<<'\n';
    else if(k==m)cout<<"kan dao le mai "<<x<<" de"<<'\n';
    else cout<<"wang le zhao mai "<<x<<" de"<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

D.

二分猜数字

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    int n;cin>>n;
    int l=1,r=n,mid;
    int ans;
    while(l<=r){
        mid=(l+r)/2;
        cout<<mid<<endl;
        string s;cin>>s;
        if(s.size()==1)r=mid-1;
        else {
            ans=mid;
            l=mid+1;
        }
    }
    cout<<"! "<<ans<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

E.

两个字符串分别处理完再比较是否相同

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    string s1,s2;cin>>s1>>s2;
    string t1="",t2="";
    for(int i=1;i<s1.size();i++){
        if(s1[i]%2==s1[i-1]%2){
            t1+=max(s1[i],s1[i-1]);
        }
    }
    for(int i=1;i<s2.size();i++){
        if(s2[i]%2==s2[i-1]%2){
            t2+=max(s2[i],s2[i-1]);
        }
    }
    if(t1==t2)cout<<t1<<'\n';
    else {
        cout<<t1<<'\n'<<t2<<'\n';
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

F.

字符串各种函数的运用

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    string s;cin>>s;
    int n;cin>>n;
    while(n--){
        int l,r;cin>>l>>r;
        string st,en;cin>>st>>en;
        string t=s.substr(l-1,r-l+1);
        s=s.substr(0,l-1)+s.substr(r,s.size()-r);
        en=st+en;
        int id=s.find(en);
        if(id==-1||id>0x3f3f3f3f)s+=t;
        else{
            s.insert(id+st.size(),t);
        }
    }
    cout<<s<<'\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

G.

排序+计数

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e6+10;

void solve(){
    int n;cin>>n;
    vector<int>a,cnt(N);
    for(int i=1,x;i<=n;i++){
        cin>>x;
        if(cnt[x])cnt[x]++;
        else {
            a.push_back(x);
            cnt[x]++;
        }
    }
    sort(a.begin(),a.end());
    cout<<a[0]<<' '<<cnt[a[0]]<<'\n';
    cout<<a[a.size()-1]<<' '<<cnt[a[a.size()-1]];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

H.

枚举,判素数

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e6+10;

void solve(){
    int l,k;cin>>l>>k;
    string s;cin>>s;
    if(k>s.size()){
        cout<<"404"<<'\n';
        return ;
    }
    for(int i=0;i<=s.size()-k;i++){
        int sum=0;
        for(int j=i;j<i+k;j++){
            sum=sum*10+(s[j]-'0');
        }
        if(sum==0||sum==1)continue;
        bool f=0;
        for(int j=2;j*j<=sum;j++){
            if(sum%j==0){
                f=1;
                break;
            }
        }
        if(f)continue;
        printf("%0*lld\n",k,sum);
        return ;
    }
    cout<<"404";
}

signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

J.

模拟,用栈、队列、vector

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N=1e5+10;

void solve(){
    vector<vector<int>>ans;
    int n,m,k;cin>>n>>m>>k;
    stack<int>box;
    vector<int>tree;
    queue<int>push;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        push.push(x);
    }
    while(box.size()||push.size()){
        int tmp;
        if(tree.size()!=0)tmp=tree.back();
        else tmp=0x3f3f3f3f;
        if(box.size()!=0&&box.top()<=tmp){
            tree.push_back(box.top());
            box.pop();
            if(tree.size()==k){
                ans.push_back(tree);
                tree.clear();
            }
        }else if(push.size()!=0&push.front()<=tmp){
            tree.push_back(push.front());
            push.pop();
            if(tree.size()==k){
                ans.push_back(tree);
                tree.clear();
            }
        }else if(push.size()&&box.size()<m){
            box.push(push.front());;
            push.pop();
        }else{
            ans.push_back(tree);
            tree.clear();
        }
    }
    if(tree.size()!=0){
        ans.push_back(tree);
    }
    for(int i=0;i<ans.size();i++){
        for(int j=0;j<ans[i].size();j++){
            cout<<ans[i][j];
            if(j!=ans[i].size()-1)cout<<' ';
        }
        cout<<'\n';
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int hey_left=1;
    //cin>>hey_left;
    while(hey_left--){
        solve();
    }
}

标签:winter,int,SMU,hey,long,cin,2024,solve,left
From: https://www.cnblogs.com/wwww-/p/17990795

相关文章

  • 2024年1月Java项目开发指南15:vue3+AntDesignVue 设计页面
    考虑到有的同学对vue3不熟悉,因此,我把ControlView.vue这个页面清空,我们从0开始写。<templatestyle="width:100%"></template><scriptsetup></script><stylescoped></style>搭建页面的基本框架展开代码后复制你需要的代码。比如我选择上中下这种结构,我就复制上......
  • 【随笔】2024年1月1日
    关于Febonacci的一些事学了矩阵加速递推遂顺手给你谷的板子题又过了一遍对于“已知递推式求转移矩阵”的方法仍有疑惑与巨佬WPP交流并丢给WPP一道题请他口糊题:求Febonacci前n项的和(n<=1e18)正解是把S(n)(表示前n项的和)塞到矩阵里一起转移答案矩阵F(n)={f(n-1)f(n-2)S(n......
  • 2024 蓝桥杯模拟赛 1
    P8761[蓝桥杯2021国BC]大写#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongusingvi=vector<int>;usingi32=int32_t;usingpii=pair<int,int>;i32main(){strings;cin>>s;for(auto&i......
  • Hello 2024
    AWalletExchange题目大意Alice有a个硬币,Bob有b个硬币,双方轮流进行以下操作:1.与对方交换硬币,或者保留现有硬币.2.取出一个硬币无法进行操作的人判定为输,总是从Alice开始操作问:哪位获得胜利解题思路我们可以把游戏看作是轮流取硬币,取得最后一个硬币的为胜利那......
  • PKUWC 2024 Day 1
    大致的题面如下:T1Alice和Bob玩游戏。有一个长度为\(N\)的字符串\(S\),由L和R组成。Alice先手,Bob后手。他们可以:选择一个\(i\)。如果\(S_i\)=L,那么只保留\(S_{1\simi-1}\)。如果\(S_i\)=R,那么只保留\(S_{i+1,|S|}\)。第一个遇到\(S\)空了的输掉。问谁会......
  • 2024年1月Java项目开发指南14:关于post中的body和param以及java中的@RequestBody和@Req
    在HTTP请求中,POST方法通常用于向服务器发送数据,这些数据可以在请求的body中,也可以在URL的param中。不过,这两者的使用方式和适用场景是不同的。Body:在POST请求中,body主要用于包含要发送到服务器的数据。这些数据通常是表单数据、JSON数据或其他类型的数据。当你需要在请求体中发送......
  • SMU 2024 winter round1
    7-1最好的文档#include<bits/stdc++.h>usingnamespacestd;usingi32=int32_t;i32main(){ios::sync_with_stdio(false),cin.tie(nullptr);cout<<"Goodcodeisitsownbestdocumentation.";return0;}7-2自动编程#includ......
  • 2024年可以提高工作效率的待办事项提醒软件
    对于上班族来说,追求升职加薪始终是一个不断努力的目标,而提升工作效率则成为必备的一环。在繁忙的工作生活中,一个可靠的待办事项提醒软件就成了事业成功的得力助手。那么2024年口碑很好的待办事项提醒软件是哪个呢?在2024年,备受好评的待办事项提醒软件中,敬业签成为许多上班族的选择......
  • 20240126打卡——《构建之法》第5~8章
    第五章团队和流程5.2软件团队的模式主治医师模式、明星模式、社区模式、业余剧团模式、秘密团队、特工团队、交响乐团模式、爵士乐模式、功能团队模式、官僚模式5.3开发流程①写了再改模式②瀑布模型(WaterfallModel)是一个项目开发架构,开发过程是通过设计一系列阶段顺序......
  • P10083 [GDKOI2024 提高组] 不休陀螺
    前置题目:石头剪刀布大赛很经典的问题,可以参考一个比这个简单容易想的*2500的做法。先想判定条件再考虑怎么计数。因为少写了一个case导致Au\(\to\)Ag,有点难评。不难想到记录\(c_i=b_i-a_i\)。我们考虑怎样才能无限下去:卡牌打完之后的费用变化是正的,不然会一直......