結果

問題 No.254 文字列の構成
ユーザー GrenacheGrenache
提出日時 2015-07-27 17:39:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 1,094 bytes
コンパイル時間 3,403 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 56,128 KB
最終ジャッジ日時 2023-09-23 03:59:41
合計ジャッジ時間 9,865 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,652 KB
testcase_01 AC 126 ms
55,684 KB
testcase_02 AC 125 ms
55,692 KB
testcase_03 AC 128 ms
55,640 KB
testcase_04 AC 125 ms
55,896 KB
testcase_05 AC 125 ms
56,128 KB
testcase_06 AC 127 ms
55,864 KB
testcase_07 AC 127 ms
55,464 KB
testcase_08 AC 127 ms
55,808 KB
testcase_09 AC 127 ms
56,064 KB
testcase_10 AC 128 ms
55,528 KB
testcase_11 AC 126 ms
55,504 KB
testcase_12 AC 128 ms
53,596 KB
testcase_13 AC 126 ms
55,464 KB
testcase_14 AC 127 ms
55,800 KB
testcase_15 AC 137 ms
55,888 KB
testcase_16 AC 138 ms
53,508 KB
testcase_17 AC 141 ms
55,528 KB
testcase_18 AC 142 ms
55,788 KB
testcase_19 AC 142 ms
55,660 KB
testcase_20 AC 142 ms
55,844 KB
testcase_21 AC 144 ms
55,564 KB
testcase_22 AC 140 ms
55,656 KB
testcase_23 AC 141 ms
55,784 KB
testcase_24 AC 140 ms
55,720 KB
testcase_25 AC 142 ms
55,892 KB
testcase_26 AC 142 ms
55,464 KB
testcase_27 AC 142 ms
55,544 KB
testcase_28 AC 140 ms
55,548 KB
testcase_29 AC 143 ms
55,260 KB
testcase_30 AC 141 ms
55,628 KB
testcase_31 AC 139 ms
56,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main_yukicoder254 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        int n = sc.nextInt();
        StringBuilder ret = new StringBuilder();
        char base = 'a';
        
        while (n > 0) {
            int tmp = (int)Math.sqrt(n);

            if (tmp > 1) {
            	for (int i = 0; i < tmp - 1; i++) {
            		ret.append(base);
            		ret.append((char)(base + 1));
            	}
            	ret.append(base);
            	base += 2;
            	if (base > 'v') {
            		base = 'a';
            	}

            	n -= tmp * tmp;
            } else {
            	for (int i = 0; i < n; i++) {
            		ret.append(base++);
            	}
            	n = 0;
            }
        }

        pr.println(ret);

        pr.close();
        sc.close();
    }

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0