結果

問題 No.237 作図可能性
コンテスト
ユーザー bal4u
提出日時 2019-05-11 19:55:31
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 761 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 121 ms
コンパイル使用メモリ 38,596 KB
最終ジャッジ日時 2026-02-22 03:21:38
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: No.237 作図可能性
// 2019.5.11

#include <stdio.h>

#define MAX 1000000000
// #define FLEN 5
// int fermat[] = { 3, 5, 17, 257, 65537 };
int fn[] = { 1,3,5,15,17,51,85,255,257,771,1285,3855,4369,
  13107,21845,65535,65537,196611,327685,983055,1114129,3342387,
  5570645,16711935,16843009,50529027,84215045,252645135,
286331153,858993459, MAX+1 };
#define PLEN 31
int p2[35];

int bsch(int x) {
	int m, l = 0, r = PLEN;
    while (l < r) {
        m = (l+r) >> 1;
        if (p2[m] <= x) l = m + 1; else r = m;
    }
	if (l == 0) return 1;
	return l;
}

int main()
{
	int i, A, ans;
	
	for (i = 0; i < PLEN; i++) p2[i] = 1<<i;
	scanf("%d", &A);
	ans = 0; for (i = 0; fn[i] <= A; i++) ans += bsch(A/fn[i]);
	printf("%d\n", ans-2);
	return 0;
}
0