栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

2021年冬季PAT乙级题解(C/C++语言)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021年冬季PAT乙级题解(C/C++语言)

2021年冬季PAT乙级题解(C/C++语言) 7-1 自动打包机 (15 分) 原题

算法标签 模拟 代码
#include
#define int long long
using namespace std;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N,W,tW;
    cin>>N>>W;
    tW=W;
    int res=0,cnt=0, ress=0;
    while(N--){
        int num;
        cin>>num;
        if(W>=num){
            W-=num;
            cnt++;
            if(!W){
                res++;
                W=tW;
                ress+=cnt;
                cnt=0;
            }
        }
    }
    cout< 
用药统计 
原题 

算法标签 模拟 结构体 代码
#include
#define int long long
#define x first
#define y second
using namespace std;
const int N = 10005, K = 15;
struct Ill{
    string id;
    int k;
    string drug[K];
}ill[N];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    map mp;
    vector vs;
    cin>>N;
    for(int i=0;i>ill[i].id>>ill[i].k;
        for(int j=0;j>ill[i].drug[j];
            mp[ill[i].drug[j]]++;
        }
    }
    int mx=0 ;
    string mxidx="";
    for(auto it: mp){
        if(it.y>mx){
            mx = it.y;
            mxidx = it.x;
        }
    }
    for(int i=0;i 
五彩斑斓的黑 
原题 

算法标签 模拟 代码
#include
#define int long long
using namespace std;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    unordered_map mp;
    cin>>n;
    for(int i=0;i>s;
        mp[s]++;
    }
    cout< 
假新闻 
原题 

算法标签 模拟 排序 代码
#include
#define int long long
using namespace std;
const int N = 10005, M = 105;
int a[M][N], b[M][N], c[N], mx[M];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i>a[i][j];
        }
    }
    for(int i=0;iMx){
                Mx = b[i][j];
            }
        }
        mx[i]=Mx;
    }
    for(int i=0;iMax){
            Max=c[i];
            Maxidx=i;
        }
    }
    cout< 
静态链表的秩 
原题 

算法标签 模拟 链表 排序 代码 排序
#include
#define int long long
using namespace std;
const int N = 100005;
int a[N], b[N], c[N], d[N];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i>a[i];
        c[i]=a[i];
    }
    sort(c, c+n);
    int head=0;
    for(int i=0;i 

上述代码对于测试样例无问题,可能存在bug, 遇到问题欢迎一起交流沟通哈。
原创不易 转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/889709.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号