結果
問題 |
No.149 碁石の移動
|
ユーザー |
![]() |
提出日時 | 2025-03-07 10:19:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,339 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 26,880 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-07 10:19:48 |
合計ジャッジ時間 | 1,310 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 4 WA * 9 |
コンパイルメッセージ
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 = whiteA; black = AtoB - whiteA; whiteA -= white; blackA -= black; //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 = BtoA - whiteB; black = whiteB; whiteB -= white; blackB -= black; //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); }