1 条题解

  • 0
    @ 2024-5-10 0:45:59

    C :

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
        int r,w,l,n=0;
        while(scanf("%d",&r)!=EOF,r)
        {
            scanf("%d%d",&w,&l);
            if(r*2>=sqrt(w*w+l*l))
                printf("Pizza %d fits on the table.\n",++n);
            else
                printf("Pizza %d does not fit on the table.\n",++n);
        }
        return 0;
    }
    

    C++ :

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
        int r,w,l,n=0;
        while(scanf("%d",&r)!=EOF,r)
        {
            scanf("%d%d",&w,&l);
            if(r*2>=sqrt(w*w+l*l))
                printf("Pizza %d fits on the table.\n",++n);
            else
                printf("Pizza %d does not fit on the table.\n",++n);
        }
        return 0;
    }
    

    Pascal :

    var
      i,l,w,r:integer;
    x:real;
    begin
    repeat
    i:=i+1;
    read(r,l,w);
    if r=0 then break;
    x:=sqrt(sqr(l)+sqr(w));
    if x<=2*r then writeln('Pizza ',i,' fits on the table.') 
                 else writeln('Pizza ',i,' does not fit on the table.');
    until r=0;
    end.
    

    Java :

    import java.util.*;
    
    public class Main{
        public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int i = 0;
        while(in.hasNextInt()){
            i++;
            int r = in.nextInt();
            if(r==0) break;
            int w = in.nextInt();
            int l = in.nextInt();
            int W = (int)Math.pow(w,2);
            int L = (int)Math.pow(l,2);
            int R = (int)Math.pow(2*r,2);
            if(W+L<=R)
                System.out.println("Pizza "+i+" fits on the table.");
            else
                System.out.println("Pizza "+i+" does not fit on the table.");
        }
    }
    }
    
    • 1

    信息

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