結果

問題 No.254 文字列の構成
ユーザー tentententen
提出日時 2020-12-23 12:05:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 186 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 76,420 KB
実行使用メモリ 58,528 KB
最終ジャッジ日時 2023-10-21 15:08:00
合計ジャッジ時間 9,724 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
58,440 KB
testcase_01 AC 163 ms
58,472 KB
testcase_02 AC 163 ms
58,284 KB
testcase_03 AC 159 ms
58,440 KB
testcase_04 AC 159 ms
58,300 KB
testcase_05 AC 161 ms
58,460 KB
testcase_06 AC 161 ms
58,444 KB
testcase_07 AC 162 ms
58,428 KB
testcase_08 AC 160 ms
58,448 KB
testcase_09 AC 163 ms
58,468 KB
testcase_10 AC 164 ms
58,460 KB
testcase_11 AC 163 ms
58,240 KB
testcase_12 AC 166 ms
58,392 KB
testcase_13 AC 164 ms
58,448 KB
testcase_14 AC 161 ms
58,440 KB
testcase_15 AC 165 ms
58,456 KB
testcase_16 AC 171 ms
58,448 KB
testcase_17 AC 183 ms
58,516 KB
testcase_18 AC 184 ms
58,328 KB
testcase_19 AC 180 ms
58,516 KB
testcase_20 AC 179 ms
58,512 KB
testcase_21 AC 184 ms
58,520 KB
testcase_22 AC 176 ms
58,328 KB
testcase_23 AC 174 ms
58,288 KB
testcase_24 AC 172 ms
58,336 KB
testcase_25 AC 182 ms
58,324 KB
testcase_26 AC 186 ms
58,528 KB
testcase_27 AC 185 ms
58,520 KB
testcase_28 AC 173 ms
58,524 KB
testcase_29 AC 183 ms
58,292 KB
testcase_30 AC 183 ms
58,512 KB
testcase_31 AC 170 ms
58,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] counts = new int[40000];
        counts[1] = 1;
        for (int i = 2; i < 40000; i++) {
            counts[i] = counts[i - 1] + 2 + i - 1 + i - 2;
        }
        StringBuilder sb = new StringBuilder();
        int idx = 0;
        for (int i = 39999; i >= 1; i--) {
            while (n >= counts[i]) {
                n -= counts[i];
                String tmp = (char)(idx % 26 + 'a') + "" + (char)((idx + 1) % 26 + 'a');
                for (int j = 1; j < i; j++) {
                    sb.append(tmp);
                }
                sb.append((char)(idx % 26 + 'a'));
                idx += 2;
            }
        }
        System.out.println(sb);
    }
}
0