結果

問題 No.781 円周上の格子点の数え上げ
ユーザー bal4ubal4u
提出日時 2019-05-06 06:17:43
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 616 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 28,676 KB
実行使用メモリ 40,968 KB
最終ジャッジ日時 2023-09-09 04:51:22
合計ジャッジ時間 14,334 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 612 ms
40,852 KB
testcase_01 AC 616 ms
40,876 KB
testcase_02 AC 606 ms
40,848 KB
testcase_03 AC 601 ms
40,780 KB
testcase_04 AC 610 ms
40,968 KB
testcase_05 AC 575 ms
40,844 KB
testcase_06 AC 578 ms
40,912 KB
testcase_07 AC 585 ms
40,892 KB
testcase_08 AC 576 ms
40,880 KB
testcase_09 AC 561 ms
40,908 KB
testcase_10 AC 565 ms
40,884 KB
testcase_11 AC 573 ms
40,916 KB
testcase_12 AC 550 ms
40,776 KB
testcase_13 AC 565 ms
40,912 KB
testcase_14 AC 567 ms
40,912 KB
testcase_15 AC 545 ms
40,912 KB
testcase_16 AC 556 ms
40,776 KB
testcase_17 AC 542 ms
40,884 KB
testcase_18 AC 534 ms
40,792 KB
testcase_19 AC 550 ms
40,896 KB
testcase_20 AC 560 ms
40,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.781 円周上の格子点の数え上げ
// 2019.5.6 bal4u

#include <stdio.h>

#define MAX  10000000
#define MAX2 5000000
int a[MAX+5];
int d[4] = {0,1,0,-1};

void precalc() {  // 約数の処理
	int i, j, k;
	
	a[1] = 1;
	for (i = 2; i <= MAX; i++) {
		a[i] = 1 + d[i & 3];	// 約数1とi
	}
	for (i = 2; i <= MAX2; i++) {
		k = d[i & 3];
		if (k == 0) continue;
		for (j = i<<1; j <= MAX; j += i) a[j] += k;
	}
}

int main()
{
	int X, Y, max;

	precalc();
	scanf("%d%d", &X, &Y);
	max = 0; while (X <= Y) {
		if (a[X] > max) max = a[X];
		X++;
	}
	printf("%d\n", max << 2);
	return 0;
}
0