結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー Maeda
提出日時 2025-03-19 16:21:32
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 215 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 24,960 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-19 16:21:34
合計ジャッジ時間 1,838 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
    9 |                 printf("%d",n-2);
      |                         ~^  ~~~
      |                          |   |
      |                          int long int
      |                         %ld
main.c:11:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   11 |                 printf("%d",n-1);
      |                         ~^  ~~~
      |                          |   |
      |                          int long int
      |                         %ld
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 || n%2 != 0 && k%2 == 0){
		printf("%d",n-2);
	}else{
		printf("%d",n-1);
	}
}
0