1 条题解
-
0
C :
#include<stdio.h> int main() { int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e); a=a/3; b=a+b; e=a+e; b=b/3; a=a+b; c=b+c; c=c/3; b=b+c; d=c+d; d=d/3; c=c+d; e=e+d; e=e/3; d=d+e; a=a+e; printf("%d %d %d %d %d",a,b,c,d,e); return 0; }C++ :
#include<iostream> using namespace std; int main(){ int a,b,c,d,e; cin>>a>>b>>c>>d>>e; a = a / 3; // 0 b = b + a; // 2 e = e + a; // 5 b = b / 3; // 0 a = a + b; //0 c = c + b; //3 c = c / 3; // 1 b = b + c; // 1 d = d + c; // 5 d = d / 3; c = c + d; e = e + d; e = e / 3; d = d + e; a = a + e; cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e; return 0; }Pascal :
var a,b,c,d,e,f:integer; begin read(a,b,c,d,e); f:=a div 3; a:=f; b:=b+f; e:=e+f; f:=b div 3; b:=f; a:=a+f; c:=c+f; f:=c div 3; c:=f; b:=b+f; d:=d+f; f:=d div 3; d:=f; c:=c+f; e:=e+f; f:=e div 3; e:=f; a:=a+f; d:=d+f; write(a,' ',b,' ',c,' ',d,' ',e); end.Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int d = in.nextInt(); int e = in.nextInt(); int a1 =a%3; if(a1==0){ b=b+a/3; e=e+a/3; a=a/3; }else{ b=b+a/3; e=e+a/3; a=a/3; } int b1 =b%3; if(b1==0){ a=a+b/3; c=c+b/3; b=b/3; }else{ a=a+b/3; c=c+b/3; b=b/3; } int c1 =c%3; if(c1==0){ b=b+c/3; d=d+c/3; c=c/3; }else{ b=b+c/3; d=d+c/3; c=c/3; } int d1 =d%3; if(d1==0){ c=c+d/3; e=e+d/3; d=d/3; }else{ c=c+d/3; e=e+d/3; d=d/3; } int e1 =e%3; if(e1==0){ d=d+e/3; a=a+e/3; e=e/3; }else{ d=d+e/3; a=a+e/3; e=e/3; } System.out.print(a+" "+b+" "+c+" "+d+" "+e); } }Python :
a,b,c,d,e=map(int,input().split()) a=a//3;b=b+a;e=e+a;b=b//3;c=c+b;a=a+b;c=c//3;b=b+c;d=d+c;d=d//3;c=c+d;e=e+d;e=e//3;d=d+e;a=a+e; print(a,b,c,d,e)
- 1
信息
- ID
- 31
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 8
- 已通过
- 1
- 上传者