思路代码都和别人AC代码一样,但是不晓得为什么我用java写的就er了4个

P1319 压缩技术

哆啦啊梦 @ 2022-01-15 03:31:52

代码如下


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a=scanner.nextInt();
        int sum=0;
        while (sum<a*a){
            int m=scanner.nextInt();
            for(int k=0;k<m;k++){
                System.out.print("0");
                if((sum+1)%a==0) System.out.print("\n");
                sum++;
            }
            int n=scanner.nextInt();
            for(int k=0;k<n;k++){

                System.out.print("1");
                if((sum+1)%a==0) System.out.print("\n");
                sum++;
            }
        }
    }
}

|