結果

問題 No.1946 ロッカーの問題
ユーザー pengin_2000pengin_2000
提出日時 2022-07-02 11:37:34
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 203 ms / 3,000 ms
コード長 533 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 29,476 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 02:43:37
合計ジャッジ時間 4,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 203 ms
4,376 KB
testcase_03 AC 71 ms
4,376 KB
testcase_04 AC 202 ms
4,380 KB
testcase_05 AC 127 ms
4,380 KB
testcase_06 AC 150 ms
4,376 KB
testcase_07 AC 104 ms
4,380 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 62 ms
4,380 KB
testcase_10 AC 51 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 45 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 9 ms
4,384 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 18 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int a[200005];
int t[200005], s[200005];
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	for (i = 0; i < m; i++)
		scanf("%d", &a[i]);
	for (i = 1; i <= n; i++)
		t[i] = n / i % 2;
	for (i = 0; i <= n; i++)
		s[i] = 0;
	for (i = 0; i < m; i++)
		s[a[i]] = 1;
	int ans = 0;
	for (i = n; i > 0; i--)
	{
		if (s[i] == t[i])
			continue;
		ans++;
		for (j = 1; j * j <= i; j++)
		{
			if (i % j > 0)
				continue;
			s[j] ^= 1;
			if (j * j < i)
				s[i / j] ^= 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}
0