結果

問題 No.701 ひとりしりとり
ユーザー tentententen
提出日時 2022-10-06 13:14:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,286 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 54,392 KB
最終ジャッジ日時 2023-08-30 23:50:31
合計ジャッジ時間 3,997 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,404 KB
testcase_01 AC 44 ms
49,408 KB
testcase_02 AC 43 ms
49,336 KB
testcase_03 AC 43 ms
49,836 KB
testcase_04 AC 43 ms
49,224 KB
testcase_05 AC 44 ms
49,348 KB
testcase_06 AC 42 ms
49,296 KB
testcase_07 AC 43 ms
49,612 KB
testcase_08 AC 43 ms
49,312 KB
testcase_09 AC 48 ms
49,416 KB
testcase_10 AC 76 ms
50,860 KB
testcase_11 AC 122 ms
54,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

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 > 0) {
                sb.append((char)(x % 26 + 'a'));
                x /= 26;
            }
            sb.append("a\n");
        }
        sb.append("an");
        System.out.println(sb);
    }
}
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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0