#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int four9[40];
int six6[40];
int d,l;
int *p;
void dfs(int depth,int sum){
if(depth == d){
p[sum]++;return;
}
for(int i = 1;i <= l; ++i){
dfs(depth + 1,sum + i);
}
}
int main(){
memset(four9,0,sizeof(four9));
memset(six6,0,sizeof(six6));
p = four9;d = 9,l = 4;
dfs(0,0);
p = six6;d = 6,l = 6;
dfs(0,0);
long long numerator = 0;
for(int i = 1;i <= 36; ++i) printf("%d ",four9[i]);printf("\n");
for(int i = 1;i <= 36; ++i) printf("%d ",six6[i]);printf("\n");
for(int i = 4;i <= 36; ++i){
for(int j = 6;j <= 36; ++j){
if(i > j) numerator += 1LL * four9[i] * six6[j];
}
}
printf("%.7f\n",1.0 * numerator / (pow(4.0,9) * pow(6.0,6)));
return 0;
}
لینک سوال در ProjectEuler