結果

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

テストケース

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

ソースコード

diff #

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

using namespace std;

int checkPic(string tmp, vector<string> coinNameArray);


int main() {

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

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

    for (int i = 0; i < 3; i++)
    {
        cin >> n[i];
        leel[i].resize(n[i]);
        for (int j = 0; j < n[i]; j++)
        {
            cin >> tmpPic;
            picNumber[i][checkPic(tmpPic, coinNameArray)]++;
            leel[i][j]=tmpPic;
        }
    }

    for(int i=0; i<5; i++)
    {
        tmpExpect= ((picNumber[0][i]/(double)n[0])*(picNumber[1][i]/(double)n[1])*(picNumber[2][i]/(double)n[2])*(double)coinNumber[i]);
        expectValue += tmpExpect;
        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;
}

int checkPic(string tmp, vector<string> coinNameArray)
{
    for(int i=0; i<5; i++)
    {
        if(tmp == coinNameArray[i])
            return i;
    }

    return 0;
}
0