結果
| 問題 |
No.149 碁石の移動
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-07 10:01:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 685 bytes |
| コンパイル時間 | 439 ms |
| コンパイル使用メモリ | 26,880 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-07 10:01:44 |
| 合計ジャッジ時間 | 1,450 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 5 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d%d",&whiteA,&blackA);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d%d",&whiteB,&blackB);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d",&AtoB,&BtoA);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main(){
// 袋Aの白と黒の数
int whiteA,blackA;
scanf("%d%d",&whiteA,&blackA);
// 袋Bの白と黒の数
int whiteB,blackB;
scanf("%d%d",&whiteB,&blackB);
// 碁石を移動した数
int AtoB,BtoA;
scanf("%d%d",&AtoB,&BtoA);
// 袋Aから取り出す
int white,black;
if(blackA < AtoB){
white = AtoB - whiteA;
black = whiteA;
}else{
white = 0;
black = AtoB;
}
// 袋Bに入れる
whiteB += white;
blackB += black;
// 袋Bから取り出す
if(whiteB < BtoA){
white = whiteB;
black = BtoA - whiteB;
}else{
white = BtoA;
black = 0;
}
// 袋Aに入れる
whiteA += white;
blackB += black;
printf("%d",whiteA);
}
sasa