結果
問題 |
No.99 ジャンピング駒
|
ユーザー |
![]() |
提出日時 | 2025-03-06 09:44:00 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 439 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 24,704 KB |
実行使用メモリ | 8,480 KB |
最終ジャッジ日時 | 2025-03-06 09:44:02 |
合計ジャッジ時間 | 1,393 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&num); | ^~~~~~~~~~~~~~~~ main.c:13:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d",&val); | ^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ // 駒の個数 int num = 0; scanf("%d",&num); // 最後まで残る駒数 int count = 0; // 駒の個数だけループ for(int i = 0;i < num;i++){ // 駒の座標 int val = 0; scanf("%d",&val); // 奇数と偶数で1セット if(val % 2 == 0){ count++; }else{ count--; } } // 絶対値を出力 if(count < 0){ printf("%d",count * -1); }else{ printf("%d",count); } }