|
|
Edited by author 13.09.2015 07:34 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 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(); } } } Edited by author 13.09.2015 07:35 1 0 1 2 1 0 3 2 3 0 2 0 1 2 3 4 1 0 3 4 5 2 3 0 5 1 3 4 5 0 2 4 5 1 2 0 My solution for "guns for battle" keeps getting marked as wrong and I don't know why. Any ideas? import java.util.*; import java.io.*; public class Gunner{ public static void main(String[] args) throws Exception{ StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(System.out); in.nextToken(); int n = (int)in.nval; int x = (2 * n) + 1;
int r = 1, c=1; while( r <= x) { while(c <= x){ if(r == c) out.print(0+" "); else out.print((r-1) + (c-1))+" "); out.flush(); ++c; } out.println(); out.flush(); c = 1; ++r; } } } "gunners" must be "guns" in "one integer n that is the number of gunners on board" Thanks, it was very useful to getting AC. How come i can write very simple counter to be AC this without any algorithm? Guys what does '?' mean? Question mark means that you have submitted something, but since standings are "frozen", no one (except you and your monkey, if one exists) knows verdict of this submit (AC, WA or whatever). Edited by author 23.12.2012 15:45 |
|
|