1 条题解

  • 0
    @ 2024-12-24 9:59:29

    C :

    #include<stdio.h>
    
    int main()
    {
    	float a,b,c,d,e,x,x1,x2,x3,x4,x5;
    	while(scanf("%f%f%f%f%f",&a,&b,&c,&d,&e)!=EOF&&a!=0&&b!=0&&c!=0&&d!=0&&e!=0)
    	{
    		if(b-a==c-b&&d-c==c-b&&e-d==d-c)
    		{
    			x=b-a;
    			x1=e+x;
    			x2=x1+x;
    			x3=x2+x;
    			x4=x3+x;
    			x5=x4+x;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    		if(b/a==c/b&&d/c==c/b&&e/d==d/c)
    		{
    			x=b/a;
    			x1=e*x;
    			x2=x1*x;
    			x3=x2*x;
    			x4=x3*x;
    			x5=x4*x;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    		if(c==a+b&&d==b+c&&e==c+d)
    		{
    			x1=d+e;
    			x2=e+x1;
    			x3=x2+x1;
    			x4=x3+x2;
    			x5=x4+x3;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    
    int main()
    {
    	float a,b,c,d,e,x,x1,x2,x3,x4,x5;
    	while(scanf("%f%f%f%f%f",&a,&b,&c,&d,&e)!=EOF&&a!=0&&b!=0&&c!=0&&d!=0&&e!=0)
    	{
    		if(b-a==c-b&&d-c==c-b&&e-d==d-c)
    		{
    			x=b-a;
    			x1=e+x;
    			x2=x1+x;
    			x3=x2+x;
    			x4=x3+x;
    			x5=x4+x;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    		if(b/a==c/b&&d/c==c/b&&e/d==d/c)
    		{
    			x=b/a;
    			x1=e*x;
    			x2=x1*x;
    			x3=x2*x;
    			x4=x3*x;
    			x5=x4*x;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    		if(c==a+b&&d==b+c&&e==c+d)
    		{
    			x1=d+e;
    			x2=e+x1;
    			x3=x2+x1;
    			x4=x3+x2;
    			x5=x4+x3;
    			printf("%.f %.f %.f %.f %.f\n",x1,x2,x3,x4,x5);
    		}
    	}
    	return 0;
    }
    

    Java :

    
    
    import java.util.Scanner;
    
    public class Main{
       private static Scanner s = new Scanner(System.in) ;
       
       public static void main(String[] args) {
    	  while(true){
    		  int a = s.nextInt() ;
    		  int b = s.nextInt() ;
    		  int c = s.nextInt() ;
    		  int d = s.nextInt() ;
    		  int e = s.nextInt() ;
    		  if(a==0&&b==0&&c==0&&d==0&&e==0){
    			  break ;
    		  }
    		  int sum = 0 ;
    		  int sum2 = 0 ;
    		  if(f(a, b, c, d, e)==1){
    			  sum = e ;
    			  for (int i = 0; i < 5; i++) {
    				  sum = sum + e - d ; 
    				  if(i==4){
    					  System.out.println(sum) ;
    				  }else {
    				
    				System.out.print(sum+" ") ;
    			}
    			  }
    		  }else if(f(a, b, c, d, e)==2){
    			  sum = e ;
    			  for (int i = 0; i < 5; i++) {
    				  sum = sum * (e / d) ; 
    				  if(i==4){
    					  
    					  System.out.println(sum) ;
    				  }else {
    				  
    					System.out.print(sum+" ") ;
    				}
    			  }
    			  
    		  }else {
    			  sum = d ;
    			  sum2 = e ;
    			  int temp = 0 ;
    			  for (int i = 0; i < 5; i++) {
    				  temp = sum2 ;
    					 sum2 = sum + sum2 ;
    					 sum = temp ;
    				  if(i==4){
    					  System.out.println(sum2) ;
    				  }else {
    				
    				 System.out.print(sum2+" ") ;
    		      }
    			  }
    		  }
    		  
    	  }
       }
       
       public static int f(int a , int b , int c , int d , int e){
    	   if((d-c==c-b)&&(e-d==d-c)&&(c-b==b-a)){
    		   return 1 ;
    	   }
    	   else if(((double)d/c==(double)c/b)&&((double)e/d==(double)d/c)&&((double)c/b==(double)b/a)){
    		   return 2 ;
    	   }
    	   else return 3 ;
       }
    }
    
    

    Python :

    # coding=utf-8
    a,b,c,d,e=map(int,input().split())
    while a!=0 or b!=0 or c!=0 or d!=0 or e!=0:
        if b-a==c-b==d-c:
            print(e+b-a,e+(b-a)*2,e+(b-a)*3,e+(b-a)*4,e+(b-a)*5)
        elif b/a==c/b==d/c:
            print(int(e*b/a),int(e*(b/a)**2),int(e*(b/a)**3),int(e*(b/a)**4),int(e*(b/a)**5))
        else:
            print(d+e,d+2*e,2*d+3*e,3*d+5*e,5*d+8*e)
        a,b,c,d,e=map(int,input().split())
    
    • 1

    信息

    ID
    1633
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者