結果

問題 No.701 ひとりしりとり
ユーザー Pump0129Pump0129
提出日時 2018-11-28 17:37:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 1,278 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 74,588 KB
実行使用メモリ 64,632 KB
最終ジャッジ日時 2023-09-09 05:49:57
合計ジャッジ時間 5,310 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,596 KB
testcase_01 AC 121 ms
56,296 KB
testcase_02 AC 121 ms
55,672 KB
testcase_03 AC 130 ms
55,772 KB
testcase_04 AC 128 ms
55,680 KB
testcase_05 AC 130 ms
55,488 KB
testcase_06 AC 128 ms
55,944 KB
testcase_07 AC 126 ms
55,436 KB
testcase_08 AC 130 ms
55,444 KB
testcase_09 AC 184 ms
55,824 KB
testcase_10 AC 277 ms
59,752 KB
testcase_11 AC 654 ms
64,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no701;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num_cnt = scan.nextInt();


        CreateMoji createMoji = new CreateMoji();

        for (int i = 0; i < num_cnt - 1; i++) {
            String moji = createMoji.createNextMoji('a', 'a');
            System.out.println(moji);
        }
        System.out.println(createMoji.createNextMoji('a', 'n'));
    }
}

class CreateMoji {
    private int[] integer_array;

    CreateMoji() {
        this.integer_array = new int[18];
    }

    public String createNextMoji(char beginChar, char endChar) {
        StringBuilder sb = new StringBuilder();

        sb.append(beginChar);

        for (int i = 0; i < 18; i++) {
            sb.append(Character.toChars(97 + integer_array[i]));
        }

        sb.append(endChar);

        integer_array[0] += 1;

        moveUp();

        return sb.toString();
    }

    private void moveUp() {
        for (int i = 0; i < 18; i++) {
            if (integer_array[i] == 26) {
                integer_array[i + 1] += 1;
                integer_array[i] = 0;
            }
        }
    }
}
0