結果
問題 | No.662 スロットマシーン |
ユーザー | weizen |
提出日時 | 2018-03-22 13:15:15 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,668 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 27,008 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 20:06:43 |
合計ジャッジ時間 | 1,963 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:33:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%s %d", strs[i], coins+i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:52:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf("%d",numX); | ~~~~~^~~~~~~~~~~ main.cpp:54:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | scanf("%s", tmp); | ~~~~~^~~~~~~~~~~ main.cpp:124:48: warning: ‘mouke’ may be used uninitialized in this function [-Wmaybe-uninitialized] 124 | for(int i = 0; i < 5; i++) mouke += count[i]*coins[i]; | ~~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> char strs[5][11]; int coins[5]; #define INDEX(A,B,C) ((A)*5*5+(B)*5+(C)) int combiA[125]; //5^3 000,001,...,444 int combiB[125]; int combiC[125]; char picA[5000]; char picB[5000]; char picC[5000]; void count_update(int a, int b, int c, int count[]){ int a0 = a/25, b0 = b/25, c0 = c/25; int a1 = (a%25)/5, b1 = (b%25)/5, c1 = (c%25)/5; int a2 = a%5, b2 = b%5, c2 = c%5; int plus = combiA[INDEX(a0,a1,a2)] * combiB[INDEX(b0,b1,b2)] * combiC[INDEX(c0,c1,c2)]; if(a0==b0 && b0==c0) count[a0]+=plus; if(a1==b1 && b1==c1) count[a1]+=plus; if(a2==b2 && b2==c2) count[a2]+=plus; if(a0==b1 && b1==c2) count[a0]+=plus; if(a2==b1 && b1==c0) count[a2]+=plus; } int numA, numB, numC; int main(){ for(int i = 0; i < 5; i++){ scanf("%s %d", strs[i], coins+i); } char tmp[11]; int * numX; char * picX; for(int x = 0; x < 3 ; x++){ if(x == 0){ numX = &numA; picX = picA; }else if(x == 1){ numX = &numB; picX = picB; }else /* x == 2 */{ numX = &numC; picX = picC; } scanf("%d",numX); for(int i = 0; i < *numX; i++){ scanf("%s", tmp); for(int j = 0; j < 5; j++){ if(strcmp(tmp,strs[j]) == 0){ picX[i] = j; break; } } } } /* for(int i = 0; i < numA; i++) printf("%d,", picA[i]); puts(""); for(int i = 0; i < numB; i++) printf("%d,", picB[i]); puts(""); for(int i = 0; i < numC; i++) printf("%d,", picC[i]); puts(""); for(int i = 0; i < 125; i++){combiA[i] = 0;} for(int i = 0; i < 125; i++){combiB[i] = 0;} for(int i = 0; i < 125; i++){combiC[i] = 0;} */ for(int i = 0; i <= numA-3 ; i++){ combiA[INDEX(picA[i],picA[i+1],picA[i+2])]++; //printf("(%d,%d,%d),%d\n",picA[i],picA[i+1],picA[i+2],INDEX(picA[i],picA[i+1],picA[i+2])); } combiA[INDEX(picA[numA-2],picA[numA-1],picA[0])]++; combiA[INDEX(picA[numA-1],picA[0],picA[1])]++; for(int i = 0; i <= numB-3 ; i++){ combiB[INDEX(picB[i],picB[i+1],picB[i+2])]++; } combiB[INDEX(picB[numB-2],picB[numB-1],picB[0])]++; combiB[INDEX(picB[numB-1],picB[0],picB[1])]++; for(int i = 0; i <= numC-3 ; i++){ combiC[INDEX(picC[i],picC[i+1],picC[i+2])]++; } combiC[INDEX(picC[numC-2],picC[numC-1],picC[0])]++; combiC[INDEX(picC[numC-1],picC[0],picC[1])]++; /* puts("combiA"); for(int i = 0; i < 125; i++){ printf("%d,",combiA[i]); if(i%10==9)puts(""); } puts("combiB"); for(int i = 0; i < 125; i++){ printf("%d,",combiB[i]); if(i%10==9)puts(""); } puts("combiC"); for(int i = 0; i < 125; i++){ printf("%d,",combiC[i]); if(i%10==9)puts(""); }*/ //それぞれの出目での儲けの和/全ての通り数 long total; long mouke; int count[5]; for(int a = 0; a < 125; a++){ for(int b = 0; b < 125; b++){ for(int c = 0; c < 125; c++){ //total += combiA[a]*combiB[b]*combiC[c]; for(int i = 0; i < 5; i++) count[i] = 0; count_update(a,b,c,count); for(int i = 0; i < 5; i++) mouke += count[i]*coins[i]; } } } printf("%.12f\n", (double)mouke/(numA*numB*numC)); for(int i = 0; i < 5; i++) count[i] = 0; //全部のリールの止まり方を試す for(int a = 0; a < 125; a++){ for(int b = 0; b < 125; b++){ for(int c = 0; c < 125; c++){ count_update(a,b,c,count); } } } for(int i = 0; i < 5; i++) printf("%d\n",count[i]); }