結果
問題 | No.701 ひとりしりとり |
ユーザー | tenten |
提出日時 | 2023-08-01 11:25:18 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 1,841 bytes |
コンパイル時間 | 2,460 ms |
コンパイル使用メモリ | 91,452 KB |
実行使用メモリ | 42,180 KB |
最終ジャッジ日時 | 2024-04-19 10:57:31 |
合計ジャッジ時間 | 3,885 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,156 KB |
testcase_01 | AC | 50 ms
37,176 KB |
testcase_02 | AC | 50 ms
37,176 KB |
testcase_03 | AC | 50 ms
36,780 KB |
testcase_04 | AC | 49 ms
37,180 KB |
testcase_05 | AC | 49 ms
37,244 KB |
testcase_06 | AC | 49 ms
37,016 KB |
testcase_07 | AC | 48 ms
37,244 KB |
testcase_08 | AC | 49 ms
37,308 KB |
testcase_09 | AC | 52 ms
37,184 KB |
testcase_10 | AC | 76 ms
38,268 KB |
testcase_11 | AC | 124 ms
42,180 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n - 1; i++) { sb.append("a"); int x = i; while (x >= 26) { sb.append((char)(x % 26 + 'a')); x /= 26; } sb.append((char)(x + 'a')); sb.append("a\n"); } sb.append("an"); System.out.println(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }