結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
sirogamichan1
|
| 提出日時 | 2020-11-25 13:13:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 3,331 bytes |
| コンパイル時間 | 4,637 ms |
| コンパイル使用メモリ | 340,224 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 19:17:08 |
| 合計ジャッジ時間 | 5,499 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
//////////////////////////////
// Check before you submit.
// #define _ATCODER_LIBRARY
const long long MOD = 1e9+7;
// const long long MOD = 998244353;
/////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#ifdef _ATCODER_LIBRARY
#include <atcoder/all>
using namespace atcoder;
#endif
// _ATCODER_LIBRARY
const long long INF = 1LL << 60;
const double PI = acos(-1);
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SUM(v) accumulate(ALL(v),0ll)
template<typename T>istream& operator>>(istream&i,vector<T>&v){REP(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;REP(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";REP(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
#define DEBUG(x);
#ifdef _DEBUG
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
#define GLIBCXX_DEBUG
#define GLIBCXX_DEBUG_PEDANTIC
#endif
// _DEBUG
int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};
void init_init_init() {ios_base::sync_with_stdio(false);cin.tie(NULL);std::cout<<fixed<<setprecision(10);}
template<class T>T up(T a, T b){assert(b);return (a+b-1)/b;}
template<typename... A>bool eq(A const&... a){auto t={a...};assert(t.size());auto tar=*t.begin();for(const auto&e:t)if(tar!=e)return false;return true;}
template<class T>bool chmin(T &a, T b){if(a>b){a=b;return false;}return true;}
template<class T>bool chmax(T &a, T b){if(a<b){a=b;return false;}return true;}
template<class T>bool chmax(T &a, initializer_list<T>l){return chmax(a,max(l));}
template<class T>bool chmin(T &a, initializer_list<T>l){return chmin(a,min(l));}
//////////////////////////////////////////////////////////////////
// My Library
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Contest Code
//////////////////////////////////////////////////////////////////
vector<ll> normal{1, 2, 3, 4, 5, 6};
vector<ll> ikasama{4, 4, 5, 5, 6, 6};
double dp1[110][1000]{};
double dp2[110][1000]{};
int main(int argc, char **argv)
{
init_init_init();
ll N, K; cin >> N >> K;
dp1[0][0] = dp2[0][0] = 1.f;
REP(i, N)
{
REP(sum, 1000)
{
REP(j, 6)
{
if (sum-normal[j]>=0)
dp1[i+1][sum] += dp1[i][sum-normal[j]] / 6;
}
REP(j, 6)
{
if (i < K)
{
if (sum-ikasama[j]>=0)
dp2[i+1][sum] += dp2[i][sum-ikasama[j]] / 6;
}
else
{
if (sum-normal[j]>=0)
dp2[i+1][sum] += dp2[i][sum-normal[j]] / 6;
}
}
}
}
double res{0.f};
REP(i, 1000)
for (ll j = i+1; j<1000; ++j)
res += dp1[N][i] * dp2[N][j];
std::cout << res << std::endl;
}
sirogamichan1