[JLOI2013]卡牌游戏
【代码】
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 60, M= 60;
double f[N][N];
int n,m,a[M];
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; ++i)
scanf("%d", &a[i]);
f[1][1] = 1;
for(int i = 2; i <= n; ++i)
for(int j = 1; j <= i; ++j)
for(int k = 1; k <= m; ++k) {
int c = a[k] % i ? a[k] % i : i;
if(c < j)
f[i][j] += f[i - 1][j - c] / m;
if(c > j)
f[i][j] += f[i - 1][i + j - c] / m;
}
for(int i = 1; i <= n; ++i) {
if(i != 1) putchar(' ');
printf("%.2f%%",f[n][i] * 100);
}
return 0;
}