結果

問題 No.254 文字列の構成
ユーザー ぴろずぴろず
提出日時 2015-07-24 23:17:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 513 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 71,384 KB
実行使用メモリ 57,732 KB
最終ジャッジ日時 2023-09-22 23:03:04
合計ジャッジ時間 8,995 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,268 KB
testcase_01 AC 124 ms
55,828 KB
testcase_02 AC 124 ms
55,868 KB
testcase_03 AC 121 ms
55,504 KB
testcase_04 AC 122 ms
55,716 KB
testcase_05 AC 121 ms
55,280 KB
testcase_06 AC 122 ms
55,584 KB
testcase_07 AC 122 ms
55,716 KB
testcase_08 AC 125 ms
55,676 KB
testcase_09 AC 122 ms
55,500 KB
testcase_10 AC 119 ms
55,912 KB
testcase_11 AC 121 ms
55,760 KB
testcase_12 AC 122 ms
55,500 KB
testcase_13 AC 122 ms
55,264 KB
testcase_14 AC 124 ms
55,720 KB
testcase_15 AC 133 ms
55,592 KB
testcase_16 AC 136 ms
55,588 KB
testcase_17 AC 141 ms
55,272 KB
testcase_18 AC 141 ms
55,484 KB
testcase_19 AC 137 ms
55,372 KB
testcase_20 AC 136 ms
55,632 KB
testcase_21 AC 138 ms
55,796 KB
testcase_22 AC 136 ms
55,776 KB
testcase_23 AC 135 ms
55,656 KB
testcase_24 AC 134 ms
55,828 KB
testcase_25 AC 136 ms
55,596 KB
testcase_26 AC 135 ms
55,580 KB
testcase_27 AC 135 ms
53,496 KB
testcase_28 AC 133 ms
55,504 KB
testcase_29 AC 137 ms
55,540 KB
testcase_30 AC 134 ms
55,904 KB
testcase_31 AC 133 ms
57,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no254;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		char c = 'a';
		while(n > 1) {
			int x = 1;
			while(x * x + x <= n) {
				x++;
			}
			x--;
			for(int i=0;i<x;i++) {
				ans.append(c);
				ans.append((char) (c+1));
			}
			n -= x * x + x;
			c = c == 'a' ? 'c' : 'a';
		}
		if (n == 1) {
			ans.append('z');
		}
		System.out.println(ans);
	}

}
0