結果

問題 No.415 ぴょん
コンテスト
ユーザー notetonous
提出日時 2016-08-27 00:31:46
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 301 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 148 ms
コンパイル使用メモリ 29,516 KB
最終ジャッジ日時 2026-02-23 22:18:31
ジャッジサーバー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 #
raw source code

#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