結果
| 問題 | No.162 8020運動 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-19 23:13:31 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,432 bytes |
| 記録 | |
| コンパイル時間 | 1,662 ms |
| コンパイル使用メモリ | 205,628 KB |
| 最終ジャッジ日時 | 2026-01-15 00:10:09 |
| 合計ジャッジ時間 | 2,401 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
次のファイルから読み込み: /usr/local/gcc-15/include/c++/15.2.0/bits/stl_algobase.h:76,
次から読み込み: /usr/local/gcc-15/include/c++/15.2.0/algorithm:62,
次から読み込み: /usr/local/gcc-15/include/c++/15.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:53,
次から読み込み: main.cpp:1:
/usr/local/gcc-15/include/c++/15.2.0/bit: In instantiation of ‘constexpr int std::__popcount(_Tp) [with _Tp = int]’:
main.cpp:47:49: required from here
47 | for(int i=0; i<n2; i++) answer += __popcount(i)*dp.at(i);
| ~~~~~~~~~~^~~
/usr/local/gcc-15/include/c++/15.2.0/bit:308:34: エラー: argument 1 in call to function ‘__builtin_popcountg’ has signed type
308 | return __builtin_popcountg(__x);
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int A; cin >> A;
double p0,p1,p2; cin >> p0 >> p1 >> p2;
p0 /= 100,p1 /= 100,p2 /= 100;
int n = 14,n2 = 1<<n;
vector<double> dp(n2);
vector<vector<pair<int,double>>> trans(n2);
for(int i=0; i<n2; i++){
for(int k=i; ; k=(k-1)&i){
double mul = 1;
for(int p=0; p<n; p++) if(i&(1<<p)){
int ok = (i>>(p+1))&1;
if(p) ok += (i>>(p-1))&1;
if(k&(1<<p)){
if(ok == 0) mul *= (1-p0);
else if(ok == 1) mul *= (1-p1);
else mul *= (1-p2);
}
else{
if(ok == 0) mul *= p0;
else if(ok == 1) mul *= p1;
else mul *= p2;
}
}
trans.at(i).push_back({k,mul});
if(k == 0) break;
}
}
dp.at(n2-1) = 2;
while(A < 80){
vector<double> next(n2);
for(int i=0; i<n2; i++){
if(dp.at(i) == 0) continue;
double d = dp.at(i);
for(auto [k,mul] : trans.at(i)) next.at(k) += d*mul;
}
swap(dp,next),A++;
}
double answer = 0;
for(int i=0; i<n2; i++) answer += __popcount(i)*dp.at(i);
cout << fixed << setprecision(20) << answer << endl;
}