标签:des style blog java color os
10 3 4 0.1 4 0.2 5 0.3 0 0
44.0%HintYou should use printf("%%") to print a ‘%‘.
#include <stdio.h> #include <iostream> #include<algorithm> using namespace std; #define N 100005 double dp[N]; struct node { int x; double y; }a[N]; double min(double a,double b) { return a<b?a:b; } int main() { int n,m; int k,i,j; while(cin>>n>>m) { if(n==0&&m==0) break; for(i=0;i<m;i++) { cin>>a[i].x>>a[i].y; a[i].y=1-a[i].y; // 得不到offer的概率 } for(i=0;i<=n;i++) dp[i]=1; for(i=0;i<m;i++) { for(j=n;j>=a[i].x;j--) { dp[j]=min(dp[j-a[i].x]*a[i].y,dp[j]); // 要么选这座大学 得不到offer (dp[j-a[i].x]*a[i].y),要么选这座大学得到offer (dp[j]) } } printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
hdu 1203 I NEED A OFFER!,布布扣,bubuko.com
标签:des style blog java color os
原文地址:http://blog.csdn.net/fyxz1314/article/details/37913983