2019.10.26 csp-s模拟测试88 反思总结
今天的主人公是什么?
60.1K!!!!
先扔代码再更新防止我等会儿一上头不打算写完题解
T1:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const double inf=;
int n,k;
double a[],f[][];
int main()
{
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)scanf("%lf",&a[i]);
sort(a+,a+n+);
n=unique(a+,a+n+)-a-;
for(int i=;i<=n;i++){
for(int j=;j<=k;j++)f[j][i]=inf;
}
f[][]=;
for(int i=;i<=n;i++){
for(int j=;j<=k;j++){
for(int l=;l<=i;l++){
f[j][i]=min(f[j][i],f[j-][l-]+(a[i]-a[l])*(a[i]-a[l]));
}
}
}
if(k>=n)printf("0.00\n");
else printf("%.2lf\n",f[k][n]);
return ;
}
T2:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int val[][],a[],n,opt,num,goal,sum;
double p[][][][],dice[][],ans[][],b[][][][];
char s[][];
int main()
{
// freopen("1.out","w",stdout);
for(int i=;i<=;i++){
for(int j=;j<=;j++)scanf("%1d",&val[i][j]);
scanf("%d",&a[i]);
}
p[a[]][a[]][a[]][a[]]=;
dice[][]=;
scanf("%d",&n);
for(int i=;i<=;i++){
for(int j=;j<=(i<<);j++){
dice[i][j]=(dice[i-][j]/3.00);
if(j)dice[i][j]+=(dice[i-][j-]/3.00);
if(j>=)dice[i][j]+=(dice[i-][j-]/3.00);
}
}
for(int i=;i<=n;i++){
memset(s[],,sizeof(s[]));
memset(s[],,sizeof(s[]));
memset(s[],,sizeof(s[]));
memset(s[],,sizeof(s[]));
scanf("%s%s",s[],s[]);
if(s[][]=='<'||s[][]=='>'){
int x;
scanf("%d",&x);
scanf("%s%s",s[],s[]);
if(s[][]=='<'){
if(s[][]=='='){
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='i')goal=;
else if(s[][]=='p')goal=;
else if(s[][]=='a')goal=;
else goal=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(s[][]=='?'){//<=?
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
for(int l=;l<=((abs(num))<<);l++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k<=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k<=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k<=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k]*dice[abs(num)][l];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k<=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k]*dice[abs(num)][l];
}
}
}
}
}
}
}
}
}
else{//<=x
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k<=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k<=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k<=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k<=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
}
}
}
}
}
}
}
else{
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='i')goal=;
else if(s[][]=='p')goal=;
else if(s[][]=='a')goal=;
else goal=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(s[][]=='?'){//<?
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
for(int l=;l<=((abs(num))<<);l++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k<x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k<x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k<x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k]*dice[abs(num)][l];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k<x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k]*dice[abs(num)][l];
}
}
}
} }
}
}
}
}
else{//<x
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k<x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k<x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k<x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k<x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
}
}
}
}
}
}
}
}
else{
if(s[][]=='='){
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='i')goal=;
else if(s[][]=='p')goal=;
else if(s[][]=='a')goal=;
else goal=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(s[][]=='?'){//>=?
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
for(int l=;l<=((abs(num))<<);l++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k>=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k>=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k>=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k]*dice[abs(num)][l];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k>=x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k]*dice[abs(num)][l];
}
}
}
} }
}
}
}
}
else{//>=x
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k>=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k>=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k>=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k>=x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
}
}
}
}
}
}
}
else{
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='i')goal=;
else if(s[][]=='p')goal=;
else if(s[][]=='a')goal=;
else goal=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(s[][]=='?'){//>?
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
for(int l=;l<=((abs(num))<<);l++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k>x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k>x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k]*dice[abs(num)][l];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k>x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k]*dice[abs(num)][l];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k>x){
if(goal==){
if(a1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(a1+(num<?-:)*l>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1+(num<?-:)*l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(b1+(num<?-:)*l>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1+(num<?-:)*l][c1][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(c1+(num<?-:)*l>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1+(num<?-:)*l][d1]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
else{
if(d1+(num<?-:)*l<=)b[][][][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else if(d1+(num<?-:)*l>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+(num<?-:)*l]+=p[a1][b1][c1][d1]*dice[abs(num)][l]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k]*dice[abs(num)][l];
}
}
}
} }
}
}
}
}
else{//>x
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
if(opt==){
for(int k=;k<=(val[][a1]<<);k++){
if(k>x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][a1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][b1]<<);k++){
if(k>x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][b1]][k];
}
}
}
else if(opt==){
for(int k=;k<=(val[][c1]<<);k++){
if(k>x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][c1]][k];
}
}
}
else{
for(int k=;k<=(val[][d1]<<);k++){
if(k>x){
if(goal==){
if(a1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(a1+num>=)b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(b1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(b1+num>=)b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else if(goal==){
if(c1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(c1+num>=)b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
else{
if(d1+num<=)b[][][][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else if(d1+num>=)b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
else b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
else{
b[a1][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[val[][d1]][k];
}
}
}
}
}
}
}
}
}
}
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
p[a1][b1][c1][d1]=b[a1][b1][c1][d1];
b[a1][b1][c1][d1]=;
// printf("%d %d %d %d %lf\n",a1,b1,c1,d1,p[a1][b1][c1][d1]);
}
}
}
}
b[][][][]=p[][][][];
}
else{
if(s[][]=='?'){
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(num<){
num=-num;
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
for(int l=;l<=(num<<);l++){
if(opt==){
if(a1-l>)b[a1-l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[][][][]+=p[a1][b1][c1][d1]*dice[num][l];
}
else if(opt==){
if(b1-l>)b[a1][b1-l][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[][][][]+=p[a1][b1][c1][d1]*dice[num][l];
}
else if(opt==){
if(c1-l>)b[a1][b1][c1-l][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[][][][]+=p[a1][b1][c1][d1]*dice[num][l];
}
else{
if(d1-l>)b[a1][b1][c1][d1-l]+=p[a1][b1][c1][d1]*dice[num][l];
else b[][][][]+=p[a1][b1][c1][d1]*dice[num][l];
}
}
}
}
}
}
}
else{
for(int a1=;a1>=;a1--){
for(int b1=;b1>=;b1--){
for(int c1=;c1>=;c1--){
for(int d1=;d1>=;d1--){
for(int l=;l<=(num<<);l++){
if(opt==){
if(a1+l<=)b[a1+l][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[][b1][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
}
else if(opt==){
if(b1+l<=)b[a1][b1+l][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[a1][][c1][d1]+=p[a1][b1][c1][d1]*dice[num][l];
}
else if(opt==){
if(c1+l<=)b[a1][b1][c1+l][d1]+=p[a1][b1][c1][d1]*dice[num][l];
else b[a1][b1][][d1]+=p[a1][b1][c1][d1]*dice[num][l];
}
else{
if(d1+l<=)b[a1][b1][c1][d1+l]+=p[a1][b1][c1][d1]*dice[num][l];
else b[a1][b1][c1][]+=p[a1][b1][c1][d1]*dice[num][l];
}
}
}
}
}
}
}
}
else{
if(s[][]=='i')opt=;
else if(s[][]=='p')opt=;
else if(s[][]=='a')opt=;
else opt=;
if(s[][]=='+')num=s[][]-'';
else num=-(s[][]-'');
if(num<){
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
if(opt==){
if(a1+num>)b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1];
else b[][][][]+=p[a1][b1][c1][d1];
}
else if(opt==){
if(b1+num>)b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1];
else b[][][][]+=p[a1][b1][c1][d1];
}
else if(opt==){
if(c1+num>)b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1];
else b[][][][]+=p[a1][b1][c1][d1];
}
else{
if(d1+num>)b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1];
else b[][][][]+=p[a1][b1][c1][d1];
}
}
}
}
}
}
else{
for(int a1=;a1>=;a1--){
for(int b1=;b1>=;b1--){
for(int c1=;c1>=;c1--){
for(int d1=;d1>=;d1--){
if(opt==){
if(a1+num<=)b[a1+num][b1][c1][d1]+=p[a1][b1][c1][d1];
else b[][b1][c1][d1]+=p[a1][b1][c1][d1];
}
else if(opt==){
if(b1+num<=)b[a1][b1+num][c1][d1]+=p[a1][b1][c1][d1];
else b[a1][][c1][d1]+=p[a1][b1][c1][d1];
}
else if(opt==){
if(c1+num<=)b[a1][b1][c1+num][d1]+=p[a1][b1][c1][d1];
else b[a1][b1][][d1]+=p[a1][b1][c1][d1];
}
else{
if(d1+num<=)b[a1][b1][c1][d1+num]+=p[a1][b1][c1][d1];
else b[a1][b1][c1][]+=p[a1][b1][c1][d1];
}
}
}
}
}
}
}
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
p[a1][b1][c1][d1]=b[a1][b1][c1][d1];
b[a1][b1][c1][d1]=;
// printf("%d %d %d %d %lf\n",a1,b1,c1,d1,p[a1][b1][c1][d1]);
}
}
}
}
b[][][][]=p[][][][];
}
}
printf("%.2lf\n",p[][][][]*100.0);
for(int a1=;a1<=;a1++){
for(int b1=;b1<=;b1++){
for(int c1=;c1<=;c1++){
for(int d1=;d1<=;d1++){
ans[][val[][a1]]+=p[a1][b1][c1][d1];
ans[][val[][b1]]+=p[a1][b1][c1][d1];
ans[][val[][c1]]+=p[a1][b1][c1][d1];
ans[][val[][d1]]+=p[a1][b1][c1][d1];
}
}
}
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
printf("%.2lf ",ans[i][j]*100.0);
}
printf("\n");
}
return ;
}
最好不要点开,关爱眼睛
T3:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
int k[],cnt[],vis[][][][];
struct node{
int d[],len;
}f[][][][],fir;
node cheng(node x,int sum){
node e;
memset(e.d,,sizeof(e.d));
e.len=x.len;
for(int i=;i<=x.len;i++){
e.d[i]+=x.d[i]*sum;
e.d[i+]+=e.d[i]/;
e.d[i]%=;
}
while(e.d[e.len+])e.len++;
return e;
}
node jia(node x,node y){
node e;
memset(e.d,,sizeof(e.d));
e.len=max(x.len,y.len);
for(int i=;i<=e.len;i++){
e.d[i]+=x.d[i]+y.d[i];
e.d[i+]+=e.d[i]/;
e.d[i]%=;
}
while(e.d[e.len+])e.len++;
return e;
}
node dfs(int x,int y,int z,int lst){
if(!x&&!y&&!z)return fir;
if(vis[x][y][z][lst])return f[x][y][z][lst];
vis[x][y][z][lst]=;
node num;
memset(num.d,,sizeof(num.d));
num.len=;
if(x){
num=jia(num,cheng(dfs(x-,y,z,),x-(lst==)));
}
if(y){
num=jia(num,cheng(dfs(x+,y-,z,),y-(lst==)));
}
if(z){
num=jia(num,cheng(dfs(x,y+,z-,),z));
}
return f[x][y][z][lst]=num;
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&k[i]);
cnt[k[i]]++;
}
memset(fir.d,,sizeof(fir.d));
fir.len=fir.d[]=;
node ans=dfs(cnt[],cnt[],cnt[],);
for(int i=ans.len;i>=;i--){
printf("%d",ans.d[i]);
}
return ;
}
果然不想写题解了【瘫】
2019.10.26 csp-s模拟测试88 反思总结的更多相关文章
- 2019.10.26 CSP%您赛第三场
\(CSP\)凉心模拟^_^ --题源\(lqx.lhc\)等各位蒟蒻 题目名称 比赛 传递消息 开关灯 源文件名 \(competition.cpp\) \(message.cpp\) \(ligh ...
- 2019.8.3 [HZOI]NOIP模拟测试12 C. 分组
2019.8.3 [HZOI]NOIP模拟测试12 C. 分组 全场比赛题解:https://pan.baidu.com/s/1eSAMuXk 刚看这题觉得很难,于是数据点分治 k只有1和2两种,分别 ...
- 2019.8.3 [HZOI]NOIP模拟测试12 B. 数颜色
2019.8.3 [HZOI]NOIP模拟测试12 B. 数颜色 全场比赛题解:https://pan.baidu.com/s/1eSAMuXk 数据结构学傻的做法: 对每种颜色开动态开点线段树直接维 ...
- 2019.8.3 [HZOI]NOIP模拟测试12 A. 斐波那契(fibonacci)
2019.8.3 [HZOI]NOIP模拟测试12 A. 斐波那契(fibonacci) 全场比赛题解:https://pan.baidu.com/s/1eSAMuXk 找规律 找两个节点的lca,需 ...
- 2019.8.14 NOIP模拟测试21 反思总结
模拟测试20的还没改完先咕着 各种细节问题=错失190pts T1大约三分钟搞出了式子,迅速码完,T2写了一半的时候怕最后被卡评测滚去交了,然后右端点没有初始化为n…但是这样还有80pts,而我后来还 ...
- 2019.8.1 NOIP模拟测试11 反思总结
延迟了一天来补一个反思总结 急匆匆赶回来考试,我们这边大家的状态都稍微有一点差,不过最后的成绩总体来看好像还不错XD 其实这次拿分的大都是暴力[?],除了某些专注于某道题的人以及远程爆踩我们的某学车神 ...
- 2019.8.9 NOIP模拟测试15 反思总结
日常爆炸,考得一次比一次差XD 可能还是被身体拖慢了学习的进度吧,虽然按理来说没有影响.大家听的我也听过,大家学的我也没有缺勤多少次. 那么果然还是能力问题吗……? 虽然不愿意承认,但显然就是这样.对 ...
- 2019/10/17 CSP模拟 总结
T1 补票 Ticket 没什么好说的,不讲了 T2 删数字 Number 很后悔的是其实考场上不仅想出了正解的方程,甚至连优化都想到了,却因为码力不足只打了\(O(n^2)\)暴力,甚至还因为细节挂 ...
- 2019.10.30 csp-s模拟测试94 反思总结
头一次做图巨的模拟题OWO 自从上一次听图巨讲课然后骗了小礼物以后一直对图巨印象挺好的233 T1: 对于XY取对数=Y*log(x) 对于Y!取对数=log(1*2*3*...*Y)=log1+lo ...
随机推荐
- java-day04
IntelliJ快捷键 导入包 alt + enter 删除光标所在行 ctrl + y 复制光标所在行 ctrl + d 格式代码 ctrl + alt + l 单行注释 ctrl + / 多行注释 ...
- django零散知识点
后端将对象以对象形式传到前端: from django.core.serializers import serialize def xxx(reqeust): project_list = model ...
- linux及windows安装maven
一.linux安装maven 1.wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6. ...
- shell脚本使用需要注意的地方
shell脚本中,函数内部定义变量可以为局部变量和全局变量,局部变量使用local定义,全局变量不带local,全局变量可以在函数外部可见,如下: #!/bin/bash function calle ...
- sshfs实践记录
sshfs是一款利器,可以将远程linux服务器的路径通过ssh协议挂载到本地指定路径.本地的文件一改动,就自动同步到远程服务器中. 本次的实验在centos 6.9中进行. 1.下载.安装所有的依赖 ...
- Hack Tools
Tools 2011-03-17 13:54:36| 分类: Security|举报|字号 订阅 Packet Shaper:Nemesis: a command line packet s ...
- day 42 02--CSS的继承性和层叠性
02--CSS的继承性和层叠性 本节目录 一 继承性 二 层叠性 三 层叠性权重相同处理 一 继承性 css有两大特性:继承性和层叠性 面向对象语言都会存在继承的概念,在面向对象语言中,继承的特点 ...
- day 39 MySQL之多表查询
MySQL之多表查询 阅读目录 一 介绍 二 多表连接查询 三 符合条件连接查询 四 子查询 五 综合练习 一 介绍 本节主题 多表连接查询 复合条件连接查询 子查询 首先说一下,我们写项目一般都 ...
- php构造方法(函数)基础
什么是构造函数呢?在回答这个问题之前,我们来看一个需求:我们在创建人类的对象时,是先把一个对象创建好后,再给他的年龄和姓名属性赋值,如果现在我要求,在创建人类的对象时,就指定这个对象的年龄和姓名,该怎 ...
- 左神算法进阶班5_4设计可以变更的缓存结构(LRU)
[题目] 设计一种缓存结构,该结构在构造时确定大小,假设大小为K,并有两个功能: set(key, value):将记录(key, value)插入该结构. get(key):返回key对应的valu ...