結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー Maeda
提出日時 2025-03-19 16:25:58
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 24,832 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-19 16:26:00
合計ジャッジ時間 1,294 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%ld %ld",&n,&k);
      |         ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void main(void) {
	long int n , k ;
	scanf("%ld %ld",&n,&k);
	if(k == 0 || k > n){
		printf("0");
	}else if(n%2 == 0 ){
		printf("%ld",n-2);
	}else{
		if((n+1)/2 == k ){
			printf("%ld",n-1);
		}else{
			printf("%ld",n-2);
		}
	}
}
0