結果

問題 No.415 ぴょん
ユーザー notetonous
提出日時 2016-08-27 00:31:46
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 20,480 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 17:35:23
合計ジャッジ時間 1,150 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |   scanf("%d %d",&N,&D);
      |   ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(){
  int N,D;
  scanf("%d %d",&N,&D);
  if(D==1){
    printf("%d\n",N-1);
    return 0;
  }
  if(D==N){
    printf("0\n");
    return 0;
  }
  if(N%2==0){
    if(D>N/2)D=N-D;
    printf("%d\n",(N-1)/2);
    return 0;
  }
  else{
    printf("%d\n",N-1);
    return 0;
  }
}
0