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