为啥全都是WA呀。。。

P1150 Peter 的烟

Aaron_Liu @ 2018-02-18 09:30:47

弄了个Java程序正要评测完给Peter呢,却都是WA,请问是怎么回事?

import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt(),cr=sc.nextInt();
        int result=0,rc=0;
        boolean whil=false;
        while(!whil){
            result+=c;
            if(c/cr>=1){
                rc+=c%cr;
                c=0;
            }else{
                System.out.println(result);
                whil=true;
            }
        }
    }
}

1:input 4 3,output 5,WA read 4 expected 5.


by Aaron_Liu @ 2018-02-18 09:31:43

等等,程序是这个:

import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt(),cr=sc.nextInt();
        int result=0,rc=0;
        boolean whil=false;
        while(!whil){
            result+=c;
            if(c/cr>=1){
                rc+=c%cr;
                c=0;
            }else{
                System.out.println(result);
                whil=true;
            }
        }
    }
}

by Aaron_Liu @ 2018-02-18 09:32:12

为啥都没颜色呀。。。


by Anguei @ 2018-02-18 10:47:18

@Aaron_Liu 因为时 Java.如果你写的是```cpp 就不会没颜色了


by Aaron_Liu @ 2018-02-18 12:12:46

@yyfcpp 请回答我的第一个问题。


|