PTA | 程序设计类实验辅助教学平台 (pintia.cn)
1 签到
#include <bits/stdc++.h> using namespace std; typedef long long ll; int read() { int x;scanf("%d",&x);return x; } int main() { // freopen("1.in","r",stdin); // freopen("3.out","w",stdout); cout<<"Problem? The Solution: Programming."; }1
2 没看懂题,但是猜题意,输出b-a
#include <bits/stdc++.h> using namespace std; typedef long long ll; int read() { int x;scanf("%d",&x);return x; } int main() { // freopen("1.in","r",stdin); // freopen("3.out","w",stdout); int a=read(),b=read(); cout<<b-a; }2
3 模拟
第一行:如果a=2或者b=1,输出-,否则如果a=0,输出biii,否则输出dudu
第二行:如果是绿灯,输出move,否则输出stop
#include <bits/stdc++.h> using namespace std; typedef long long ll; int read() { int x;scanf("%d",&x);return x; } int main() { // freopen("1.in","r",stdin); // freopen("3.out","w",stdout); int a=read(),b=read(); if(a==2||b==1) printf("-"); else if(a==0) printf("biii"); else printf("dudu"); puts(""); if(a==1) printf("move"); else printf("stop"); }3
4 用now表示当前,前i项全能的最少人数,则刚开始now=n,每次循环,拿着a[i]来更新now,公式是now=max(0,now+a-n)
#include <bits/stdc++.h> using namespace std; typedef long long ll; int read() { int x;scanf("%d",&x);return x; } int n,m,now; int main() { // freopen("1.in","r",stdin); // freopen("3.out","w",stdout); now=n=read(); m=read(); for(int i=1;i<=m;i++) { int a=read(); now=max(0,now+a-n); } cout<<now; }4
5 模拟
标签:天梯,int,long,2024,read,freopen,printf,now From: https://www.cnblogs.com/qywyt/p/18148731