結果

問題 No.964 2020
ユーザー uwiuwi
提出日時 2020-01-13 19:06:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,020 ms
コード長 1,352 bytes
コンパイル時間 3,645 ms
コンパイル使用メモリ 75,448 KB
実行使用メモリ 55,860 KB
最終ジャッジ日時 2023-08-23 11:11:58
合計ジャッジ時間 5,894 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,296 KB
testcase_01 AC 118 ms
55,520 KB
testcase_02 AC 119 ms
55,588 KB
testcase_03 AC 118 ms
55,860 KB
testcase_04 AC 120 ms
55,484 KB
testcase_05 AC 119 ms
55,500 KB
testcase_06 AC 119 ms
55,440 KB
testcase_07 AC 121 ms
55,312 KB
testcase_08 AC 120 ms
55,596 KB
testcase_09 AC 121 ms
55,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package contest200113;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

// こんなコード書くやつおらんやろ
public class A1 {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		int n = ni();
		if(!(1 <= n && n <= 10))throw new RuntimeException();
		int[] f = new int[10];
		Random gen = new Random();
		for(int i = 0;i < n;i++) {
			while(true) {
				int v = gen.nextInt(10);
				if(i == 0 && v == 0)continue;
				if(f[v] == 0) {
					f[v] += n;
					break;
				}
			}
		}
		
		for(int i = 1;i <= 9;i++) {
			if(f[i] > 0) {
				out.print(i);
				f[i]--;
				break;
			}
		}
		
		for(int i = 0;i < n*n-1;i++) {
			while(true) {
				int x = gen.nextInt(10);
				if(f[x] > 0) {
					f[x]--;
					out.print(x);
					break;
				}
			}
		}
		out.println();
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0