結果
| 問題 |
No.212 素数サイコロと合成数サイコロ (2)
|
| コンテスト | |
| ユーザー |
cureskol
|
| 提出日時 | 2020-04-11 12:35:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 5,000 ms |
| コード長 | 770 bytes |
| コンパイル時間 | 1,804 ms |
| コンパイル使用メモリ | 183,348 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 21:47:25 |
| 合計ジャッジ時間 | 2,477 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int p[6]={2,3,5,7,11,13},c[6]={4,6,8,9,10,12};
using ld=long double;
signed main(){
int P,C;cin>>P>>C;
ld A=pow(6,P+C);
map<int,int> dp;
dp[1]=1;
stack<int> sta;
while(P--){
for(auto tmp:dp)sta.push(tmp.first);
while(sta.size()){
int tmp=sta.top();sta.pop();
for(int j=0;j<6;j++){
dp[tmp*p[j]]+=dp[tmp];
}
dp.erase(tmp);
}
}
while(C--){
for(auto tmp:dp)sta.push(tmp.first);
while(sta.size()){
int tmp=sta.top();sta.pop();
for(int j=0;j<6;j++){
dp[tmp*c[j]]+=dp[tmp];
}
dp.erase(tmp);
}
}
ld sum=0;
for(auto tmp:dp)sum+=tmp.first*tmp.second;
cout<<fixed<<setprecision(12)<<sum/A<<endl;
}
cureskol