結果
問題 | No.208 王将 |
ユーザー |
![]() |
提出日時 | 2015-07-12 01:47:12 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 503 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 16:26:13 |
合計ジャッジ時間 | 1,199 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:26:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d %d", &tx, &ty); | ^~~~~~~~~~~~~~~~~~~~~~~~ main.c:27:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d %d", &ex, &ey); | ^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int abs(int n){ if(n<0){ return -1*n; } return n; } int getSymbol(int n){ if(n<0){ return -1; }else if(n>0){ return 1; }else{ return 0; } } int main(void){ int ex, ey; int tx, ty; int dis; scanf("%d %d", &tx, &ty); scanf("%d %d", &ex, &ey); if(abs(tx) > abs(ty)){ dis = abs(tx); }else{ dis = abs(ty); } if(ex == ey && tx == ty && getSymbol(ex) == getSymbol(tx) && getSymbol(ey) == getSymbol(ty)){ if(abs(tx) > abs(ex)){ dis += 1; } } printf("%d\n", dis); return 0; }