結果

問題 No.701 ひとりしりとり
ユーザー YamaKasaYamaKasa
提出日時 2018-10-01 15:45:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 2,245 ms
コンパイル使用メモリ 77,356 KB
実行使用メモリ 56,804 KB
最終ジャッジ日時 2024-04-20 14:17:52
合計ジャッジ時間 4,705 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,408 KB
testcase_01 AC 94 ms
39,924 KB
testcase_02 AC 113 ms
41,456 KB
testcase_03 AC 113 ms
41,420 KB
testcase_04 AC 118 ms
41,168 KB
testcase_05 AC 122 ms
41,128 KB
testcase_06 AC 125 ms
41,724 KB
testcase_07 AC 108 ms
40,336 KB
testcase_08 AC 118 ms
41,420 KB
testcase_09 AC 149 ms
42,080 KB
testcase_10 AC 250 ms
44,064 KB
testcase_11 AC 552 ms
56,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		String[]w = new String[n];
		char[]c = new char[26];
		for(int i = 0; i < 26; i++) {
			c[i] =  (char) ('a' + i);
		}
		int idx = 0;
		loop: for(int i = 0; i < 26; i++) {
			for(int j = 0; j < 26; j++) {
				for(int k = 0; k < 26; k++) {
					for(int l = 0; k < 26; k++) {
						for(int m = 0; m < 26; m++) {
							char []t = {'a', c[i], c[j], c[k], c[l], c[m], 'a'};
							if(idx == n - 1) {
								t[6] = 'n';
							}
							w[idx] = String.valueOf(t);
							idx ++;
							if(idx == n) {
								break loop;
							}
						}
					}
				}
			}
		}
		for(String s: w) {
			System.out.println(s);
		}
	}
}
0