結果

問題 No.662 スロットマシーン
ユーザー jiang0503jiang0503
提出日時 2018-03-21 23:38:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,263 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 80,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 01:08:10
合計ジャッジ時間 1,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <iomanip>

using namespace std;

int main() {

    double expectValue = 0;
    unsigned int coin;
    string coinName;
    vector<unsigned int> coinNumber(5);
    map<string, int> coinMap;
    unsigned int n[3];
    string tmpPic;
    vector<vector<unsigned int>> picNumber(3, vector<unsigned int>(5));
    unsigned long long matchPattern[5]={0, 0, 0, 0, 0};

    for(int i=0; i<5; ++i)
    {
        cin>>coinName>>coin;
        coinNumber[i]=coin;
        coinMap[coinName] = i;
    }

    for (int i = 0; i < 3; ++i)
    {
        cin >> n[i];
        for (int j = 0; j < n[i]; ++j)
        {
            cin >> tmpPic;
            picNumber[i][coinMap[tmpPic]]++;
        }
    }

    for(int i=0; i<5; ++i)
    {
        expectValue += ((picNumber[0][i]/(double)n[0])*(picNumber[1][i]/(double)n[1])*(picNumber[2][i]/(double)n[2])*(double)coinNumber[i]);
        matchPattern[i] = (unsigned long long)picNumber[0][i]*(unsigned long long)picNumber[1][i]*(unsigned long long)picNumber[2][i]*(unsigned long long)5;
    }

    expectValue *= 5.0;
    cout<<setprecision(7)<<expectValue<<endl;

    for (unsigned long long i : matchPattern)
        cout<< i <<endl;

    return 0;
}

0