hdu 1496 QQpet exploratory park 水概率dp

来源:互联网 发布:网络维护这个工作好吗 编辑:程序博客网 时间:2024/06/08 04:57

题目


犯了个语言的错误:
C语言中”%%”会输出一个”%”
,我在本地用1个”%”还是输出了”%”。


代码:

#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<vector>using namespace std;#define all(x) (x).begin(), (x).end()#define for0(a, n) for (int (a) = 0; (a) < (n); (a)++)#define for1(a, n) for (int (a) = 1; (a) <= (n); (a)++)#define mes(a,x,s)  memset(a,x,(s)*sizeof a[0])#define mem(a,x)  memset(a,x,sizeof a)#define ysk(x)  (1<<(x))typedef long long ll;typedef pair<int, int> pii;const int INF =0x3f3f3f3f;const int maxn=  61   ;double p[10];double dp[maxn+3][12];int T;int pos[]={  5, 12, 22, 29, 33, 38, 42, 46, 50 , 55};int main(){   std::ios::sync_with_stdio(false);   cin>>T;int kase=0;   while(T--)   {       for1(i,6)  cin>>p[i];       if(kase++)  puts("");       mem(dp,0);       dp[0][0]=1;       for0(i,maxn+1)       {           for0(j,10)           {               for1(k,6) if(i+k<=maxn)               {                   dp[i+k][j+1]+=p[k]*dp[i][j];               }           }       }       for0(i,10)       {           int x=pos[i];           for0(j,11)           {               dp[x][11]+=dp[x][j];           }           printf("%d: %.1f%%\n",x,100*dp[x][11]);       }   }   return 0;}
0 0
原创粉丝点击