結果

問題 No.294 SuperFizzBuzz
ユーザー htensaihtensai
提出日時 2020-05-12 11:24:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 848 ms / 5,000 ms
コード長 808 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 55,868 KB
最終ジャッジ日時 2023-10-11 05:32:27
合計ジャッジ時間 9,606 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
55,720 KB
testcase_01 AC 134 ms
55,776 KB
testcase_02 AC 848 ms
55,684 KB
testcase_03 AC 136 ms
55,728 KB
testcase_04 AC 133 ms
55,812 KB
testcase_05 AC 130 ms
55,860 KB
testcase_06 AC 130 ms
55,868 KB
testcase_07 AC 133 ms
55,720 KB
testcase_08 AC 173 ms
55,732 KB
testcase_09 AC 521 ms
55,708 KB
testcase_10 AC 522 ms
55,644 KB
testcase_11 AC 781 ms
55,808 KB
testcase_12 AC 810 ms
55,420 KB
testcase_13 AC 837 ms
55,708 KB
testcase_14 AC 845 ms
55,632 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 count = 0;
		int x = 0;
		int length = 1;
		while (count < n) {
		    x = 0;
		    while (count < n && x < (1 << length) - 1) {
		        x++;
    		    if (isSuper(x)) {
    		        count++;
    		    }
		    }
		    length++;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < length - 1; i++) {
		    if ((x & 1L) == 0) {
		        sb.append("3");
		    } else {
		        sb.append("5");
		    }
		    x >>= 1;
		}
		sb.reverse();
		System.out.println(sb + "5");
	}
	
	static boolean isSuper(long x) {
	    long count = 0;
	    while (x > 0) {
	        count += (x & 1L);
	        x >>= 1;
	    }
	    return (count % 3 == 2);
	}
}
0