ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1933. Guns for Battle!

java AC (to speed it up you might want to add a fastscanner)
Posted by esbybb 13 Sep 2015 07:24


Edited by author 13.09.2015 07:34
Re: java AC (to speed it up you might want to add a fastscanner)
Posted by esbybb 13 Sep 2015 07:25
3
0 2 3 4 5 6 7
2 0 4 5 6 7 1
3 4 0 6 7 1 2
4 5 6 0 1 2 3
5 6 7 1 0 3 4
6 7 1 2 3 0 5
7 1 2 3 4 5 0
Re: java AC (to speed it up you might want to add a fastscanner)
Posted by esbybb 16 Sep 2015 04:47
package timus;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;

public class p1933 {

    public static void main(String[] args) {
        InputStream is = System.in;
        Scanner sc = new Scanner(new InputStreamReader(is));
        int k = 2 * sc.nextInt() + 1;
        for (int i = 0; i < k; i++) {
            int inx = i;
            for (int j = 0; j < k; j++) {
                inx++;
                if (i == j) {
                    System.out.print("0 ");
                    continue;
                }
                if (inx > k) inx=1;
                System.out.print(inx + " ");
            }
            System.out.println();
        }
    }
}