江南信息学第八周练习20221028
比赛链接
1001 : 长方形的周长
python:

a = int(input()) b = int(input()) print((a+b)*2)
C++:

#include<bits/stdc++.h> #include<iostream> using namespace std; int main(){ int a,c; cin>>a>>c; int m = (a+c)*2; printf("%d",m); return 0; }
1002 : Alice与素数
python:

p = int(input()) print('Hello, prime '+str(p)+'!')
C++:

#include<iostream> using namespace std; int main(){ string s = "Hello, prime "; string a = "!"; string b; getline(cin,b); cout<<s+b+a<<endl; return 0; }
1003 : 3位数的每一位
python:

n=input() a=n[0] b=n[1] c=n[2] print(a+","+b+","+c)
C++:

#include<bits/stdc++.h> #include<iostream> using namespace std; int main() { int k; cin>>k; int s = k/100; int y = k/10%10; int c = k%10; printf("%d,%d,%d\n",s,y,c); return 0; }
1004 : 成绩
python:

a,b,c =map(int,input().split()) h =a*0.2 +b*0.3+c*0.5 print(int(h))
C++:

#include<iostream> #include<bits/stdc++.h> #include<stdio.h> using namespace std; int main() { double v,b,n; cin>>v>>b>>n; double z = v*0.2+b*0.3+n*0.5; printf("%.0f\n",z); return 0; }
1005 : 公平分配
python:

a,b,c=map(int,input().split()) if a==b and a==c: print("very good") elif a==b and abs(a-c)==1: print("fine") elif a==c and abs(a-b)==1: print("fine") elif b==c and abs(b-a)==1: print("fine") else: print("bad")
C++:

#include <iostream> using namespace std; int main() { int a,b,c,d; cin>>a>>b>>c; if(a==b&&b==c) cout<<"very good"; else if(a==b){ d=c; c--; d++; if(c==a||d==a) cout<<"fine"; else cout<<"bad"; } else if(a==c){ d=b; b--; d++; if(b==a||d==a) cout<<"fine"; else cout<<"bad"; } else if(b==c){ d=a; a--; d++; if(a==b||d==b) cout<<"fine"; else cout<<"bad"; } else cout<<"bad"; return 0; }
1006 : 有一门课不及格的学生
python:

a = int(input()) b = int(input()) if a<60 and b>=60: print(1) elif a>= 60 and b<60: print(1) else: print(0)
C++:

#include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; if(a<60&&b>=60||b<60&&a>=60) cout<<1; else cout<<0; return 0; }
1007 : 闰年判断
python:

n=int(input()) if n%4==0 and n%100!=0: print(1) elif n%400==0: print(1) else: print(0)
C++:

#include<bits/stdc++.h> using namespace std; int main() { int yeas; cin>>yeas; if(yeas%4==0&&yeas%100!=0||yeas%400==0){ cout<<1; } else{ cout<<0; } return 0; }
1008 : 跳绳游戏
python:

n,t = map(int,input().split()) ans1 = 0 ans2 = 0 for i in range(t): p1,p2,p3 = map(int,input().split()) p = p1+p2+p3 if p>=n: ans1 = ans1 + 1 else: ans2 = ans2 + 1 print(ans1,ans2)
C++:

#include <iostream> using namespace std; int main() { int a,d; int b,q,w,c=0,f=0,g=0; cin>>a; cin>>d; for(int i=1;i<=d;i++){ cin>>b>>q>>w; c=c+b+q+w; if(c>=a) f++; else g++; c=0; } printf("%d %d",f,g); return 0; }
1009 : 统计分数
python:

a=float(input()) b=float(input()) c=float(input()) d=float(input()) e=float(input()) f=float(input()) g=float(input()) h=float(input()) i=float(input()) s=(a+b+c+d+e+f+g+h+i)/9 print("%.2f"%(s))
C++:

#include<bits/stdc++.h> using namespace std; int main() { double a,b,s=0; for(int i=1;i<=9;i++){ cin>>b; s=s+b; } printf("%.2f",s/9); return 0; }
1010 : Feintl的1024节
python:

m,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) sum = sum(a)+sum(b) print(sum)
C++:

#include<bits/stdc++.h> using namespace std; int main() { long long a,b,c=0,d,e; cin>>a>>b; for(int i=1;i<=a;i++) { cin>>d; c=c+d; } for(int i=1;i<=b;i++) { cin>>e; c=c+e; } cout<<c; return 0; }