标签:des style blog http color os io java strong
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 2776 Accepted Submission(s): 948
解题:dp。。。
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 double dp[2][210]; 18 int main() { 19 int n,m,l,r,tmp,i,cur; 20 double ans = 0.0; 21 while(scanf("%d %d %d %d",&n,&m,&l,&r),n||m||l||r){ 22 dp[0][0] = 1; 23 for(int i = 1; i < n; i++) dp[0][i] = 0; 24 cur = 0; 25 while(m--){ 26 scanf("%d",&tmp); 27 for(i = 0; i < n; i++) 28 dp[cur^1][i] = 0.5*dp[cur][(i-tmp+n)%n] + 0.5*dp[cur][(i+tmp)%n]; 29 cur ^= 1; 30 } 31 ans = 0; 32 for(i = l-1; i < r; i++) 33 ans += dp[cur][i]; 34 printf("%.4f\n",ans); 35 } 36 return 0; 37 }
标签:des style blog http color os io java strong
原文地址:http://www.cnblogs.com/crackpotisback/p/3949054.html