2013 Asia Regional Changchun

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   for   art   

Hard Code http://acm.hdu.edu.cn/showproblem.php?pid=4813
 1 #include<cstdio> 2 char op[1024]; 3 int main(){ 4     int t,n,m; 5     while(~scanf("%d",&t)){ 6         while(t--){ 7             scanf("%d%d%s",&n,&m,op); 8             for(int i=0;i<n;i++){ 9                 for(int j=0;j<m;j++){10                     printf("%c",op[i*m+j]);11                 }12                 puts("");13             }14         }15     }16     return 0;17 }
View Code

 

Little Tiger vs. Deep Monkey http://acm.hdu.edu.cn/showproblem.php?pid=4815

dp求n個數的和為j的種數,除以總的種數就是機率,一旦機率大於等於p就是答案。

 1 #include<cstdio> 2 #include<cstring> 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 typedef __int64 LL; 5 LL dp[41][41010]; 6 int a[41]; 7 int main(){ 8     int n,t; 9     double p;10     scanf("%d",&t);11     while(t--){12         scanf("%d%lf",&n,&p);13         for(int i=1;i<=n;i++){14             scanf("%d",&a[i]);15         }16         mt(dp,0);17         dp[0][0]=1;18         for(int i=1;i<=n;i++){19             for(int j=0;j<=40000;j++){20                 dp[i][j]+=dp[i-1][j];21                 dp[i][j+a[i]]+=dp[i-1][j];22             }23         }24         LL sum=0;25         int ans=0;26         LL all=1LL<<n;27         for(int i=0;i<=40000;i++){28             sum+=dp[n][i];29             if(1.0*sum/all>=p){30                 ans=i;31                 break;32             }33         }34         printf("%d\n",ans);35     }36     return 0;37 }
View Code

 

 

 

end

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.