結果

問題 No.58 イカサマなサイコロ
ユーザー okkuukenkenokkuukenken
提出日時 2022-08-27 16:08:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,585 ms / 5,000 ms
コード長 1,045 bytes
コンパイル時間 2,637 ms
コンパイル使用メモリ 177,420 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 14:30:52
合計ジャッジ時間 6,689 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2,585 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 478 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 447 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
#include<bitset>
#include<cassert>
#include<complex>
#include<fstream>
#include<cstdlib>
#include<functional>
#include<array>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int dx[]={1,0,0,-1},dy[]={0,1,-1,0};
int cnt1[61],cnt2[61];
int main(){
	int n,k;
	cin>>n>>k;
	for(int S=0;S<pow(6,n);S++){
		int arr[10],S2=S;
		for(int i=0;i<n;i++){
			arr[i]=S2%6;
			S2/=6;
		}
		int sum1=0,sum2=0;
		for(int i=0;i<n;i++){
			sum1+=arr[i]+1;
			if(i<k)
				sum2+=arr[i]/2+4;
			else
				sum2+=arr[i]+1;
		}
		cnt1[sum1]++;
		cnt2[sum2]++;
	}
	ll ans=0;
	for(int i=n;i<=6*n;i++)
		for(int j=i+1;j<=6*n;j++)
			ans+=(ll)cnt1[i]*cnt2[j];
	cout<<fixed<<setprecision(20)<<ans/pow(6,2*n)<<endl;
}
0