結果

問題 No.237 作図可能性
ユーザー 37zigen37zigen
提出日時 2016-08-25 16:17:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 3,477 ms
コンパイル使用メモリ 79,172 KB
実行使用メモリ 54,564 KB
最終ジャッジ日時 2024-04-25 15:20:06
合計ジャッジ時間 8,352 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
54,232 KB
testcase_01 AC 126 ms
53,096 KB
testcase_02 AC 127 ms
53,968 KB
testcase_03 AC 131 ms
54,368 KB
testcase_04 AC 133 ms
54,432 KB
testcase_05 AC 123 ms
53,068 KB
testcase_06 AC 133 ms
54,120 KB
testcase_07 AC 129 ms
54,284 KB
testcase_08 AC 132 ms
54,220 KB
testcase_09 AC 135 ms
54,120 KB
testcase_10 AC 118 ms
53,060 KB
testcase_11 AC 135 ms
54,156 KB
testcase_12 AC 126 ms
54,044 KB
testcase_13 AC 124 ms
54,252 KB
testcase_14 AC 123 ms
54,152 KB
testcase_15 AC 127 ms
54,156 KB
testcase_16 AC 121 ms
53,128 KB
testcase_17 AC 123 ms
53,960 KB
testcase_18 AC 129 ms
54,116 KB
testcase_19 AC 131 ms
54,196 KB
testcase_20 AC 138 ms
54,032 KB
testcase_21 AC 125 ms
54,088 KB
testcase_22 AC 117 ms
53,024 KB
testcase_23 AC 131 ms
53,752 KB
testcase_24 AC 133 ms
54,008 KB
testcase_25 AC 132 ms
54,000 KB
testcase_26 AC 131 ms
54,224 KB
testcase_27 AC 132 ms
54,356 KB
testcase_28 AC 131 ms
54,564 KB
testcase_29 AC 127 ms
53,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package No200番台;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Q237 {
	public static void main(String[] args) {
		new Q237().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long[] F = { 3, 5, 17, 257, 65537 };
		// 正n角形が作図可能
		// ⇔2のべき乗とフェルマー素数の積でかける。
		ArrayList<Long> s = new ArrayList<>();
		for (int i = 1; i < (1 << 5); i++) {
			long tmp = 1;
			for (int shift = 0; shift <= 4; shift++) {
				if (((i >> shift) & 1) == 1) {
					tmp *= F[shift];
				}
				
			}
			if (tmp != 1) {
				s.add(tmp);
			}
		}
		long ans = 0;
		for (int i = 0; i < s.size(); i++) {
			long d = s.get(i);
//			System.out.println(d);
			if (d <= A) {
				ans += (long) (Math.log((double) A / (double) d) / Math.log(2)) + 1;
			}
		}
		ans += (long) ((Math.log(A) / Math.log(2))) - 1;
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
0