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 ...
随机推荐
- Day 6:集合(set)
集合(set)定义:由不同元素组成的集合,集合中是一组无序排列的可hash值,可以作为字典的key特性:集合里面数据类型是不可变的1.可变的数据类型:列表,字典2.不可变的数据类型:数字.元组.字符串 ...
- vue-router的访问权限管理
路由守卫(路由钩子.拦截器) vue-router 提供的导航守卫主要用来通过跳转或取消的方式守卫导航.有多种机会植入路由导航过程中:全局的, 单个路由独享的, 或者组件级的. 可以不登录直接进入系统 ...
- Spring AspectJ 切入点语法详解(7)
1.Spring AOP支持的AspectJ切入点指示符 切入点指示符用来指示切入点表达式目的,,在Spring AOP中目前只有执行方法这一个连接点,Spring AOP支持的AspectJ切入点指 ...
- Android开发 使用SparseArray代替HashMap[转载]
源作者:Android小Y链接:https://www.jianshu.com/p/1828f14d7955来源:简书 前言 Android开发中,一个好的应用,除了要有吸引人的功能和交互之外,在性能 ...
- 迭代器/生成器/装饰器 /Json & pickle 数据序列化
本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件目录结构规范 作业:ATM项目开发 1.列表生成式,迭代器&生成器 列表生成式 孩子,我现在有个需 ...
- 使用fileupload实现文件上传
一. fileupload组件工作原理 先来张图片, 帮助大家理解 fileupload核心API 1. DiskFileItemFactory构造器1) DiskFileItemFactory() ...
- 使用DUILIB建立项目
使用DUILIB加载XML界面 这篇主要目的就是教给大家怎样在自己的工程中加载XML界面,这是最基本的应用,对于界面控件响应啥的,我就不讲了,在大家懂了这个之后,我会给大家一个其它人写的博客,再看他的 ...
- HNOI2018
d1t1[HNOI/AHOI2018]寻宝游戏 感觉很神,反正我完全没想到 分开考虑每一位,对于每一位i计算一个二进制数b[i], 对于第i位,从后往前第j个数这一位是1,那么b[i]^=(1< ...
- git 命令行(三)-删除文件
在Git中,删除也是一个修改操作,我们实战一下,有一个多余的文件:src/common/Util2.js 我们需要删除这个文件, 一般情况下,你通常直接在文件管理器中把没用的文件删了,或者用 rm命令 ...
- memcache课程---3、php使用memcache缓存实例
memcache课程---3.php使用memcache缓存实例 一.总结 一句话总结: 前置:windows下安装好memcache.exe,安装好memcache的php扩展,开启memcache ...