結果

問題 No.58 イカサマなサイコロ
ユーザー okkuukenkenokkuukenken
提出日時 2022-08-27 16:10:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,583 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 4,940 ms
コンパイル使用メモリ 299,200 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 14:33:19
合計ジャッジ時間 9,032 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2,583 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 14 ms
6,940 KB
testcase_06 AC 480 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 448 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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