結果

問題 No.701 ひとりしりとり
ユーザー nanaenanae
提出日時 2018-07-20 23:35:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 861 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 73,576 KB
実行使用メモリ 69,336 KB
最終ジャッジ日時 2023-08-27 00:22:09
合計ジャッジ時間 6,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
55,536 KB
testcase_01 AC 191 ms
57,444 KB
testcase_02 AC 192 ms
57,088 KB
testcase_03 AC 191 ms
57,300 KB
testcase_04 AC 193 ms
57,232 KB
testcase_05 AC 193 ms
57,236 KB
testcase_06 AC 198 ms
56,880 KB
testcase_07 AC 196 ms
57,116 KB
testcase_08 AC 202 ms
57,340 KB
testcase_09 AC 248 ms
57,244 KB
testcase_10 AC 374 ms
63,660 KB
testcase_11 AC 861 ms
69,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] p = "abcdefghijklmopqrstuvwxyz".toCharArray();

        char last = 'a';

        for (int i = 0; i < n - 1; i++) {
            char[] mid = new char[18];
            for (int j = 0; j < 18; j++) {
                if ((i & (1<<j)) == 0) {
                    mid[j] = 'a';
                }
                else {
                    mid[j] = 'b';
                }
            }

            System.out.println(p[i%p.length] + String.valueOf(mid) + p[(i+1)%p.length]);
            last = p[(i+1)%p.length];
        }

        System.out.println(last + "n");
    }
}
0