結果
| 問題 |
No.149 碁石の移動
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-07 10:13:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,243 bytes |
| コンパイル時間 | 578 ms |
| コンパイル使用メモリ | 27,776 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-07 10:13:02 |
| 合計ジャッジ時間 | 1,148 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:34: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
11 | scanf("Bの袋初期:\n白:%d 黒:%d\n",whiteB,blackB);
| ~^ ~~~~~~
| | |
| int* int
main.cpp:11:41: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=]
11 | scanf("Bの袋初期:\n白:%d 黒:%d\n",whiteB,blackB);
| ~^ ~~~~~~
| | |
| int* int
main.cpp:15:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
15 | scanf("AからB:%d BからA:%d\n",AtoB,BtoA);
| ~^ ~~~~
| | |
| int* int
main.cpp:15:36: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=]
15 | scanf("AからB:%d BからA:%d\n",AtoB,BtoA);
| ~^ ~~~~
| | |
| int* int
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);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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);
scanf("Bの袋初期:\n白:%d 黒:%d\n",whiteB,blackB);
// 碁石を移動した数
int AtoB,BtoA;
scanf("%d%d",&AtoB,&BtoA);
scanf("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