結果

問題 No.136 Yet Another GCD Problem
ユーザー bal4u
提出日時 2019-04-13 16:29:53
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 366 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 11:11:14
合計ジャッジ時間 1,607 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.136 Yet Another GCD Problem
// 2019.4.13 bal4u

#include <stdio.h>
#include <math.h>

int main()
{
	int a, b, N, K, ans;

	scanf("%d%d", &N, &K);
	if ((N & 1) == 0) ans = N >> 1;
	else {
		b = (int)sqrt(N);
		for (a = 3; a <= b; a += 2) {
			if (N % a == 0) break;
		}
		if (a > b) ans = 1;
		else ans = N / a;
	}
	printf("%d\n", ans);
	return 0;
}
0