码迷,mamicode.com
首页 > 其他好文 > 详细

组合数学题 Codeforces Round #108 (Div. 2) C. Pocket Book

时间:2015-07-18 14:01:35      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

 

题目传送门

 1 /*
 2     题意:每一次任选i,j行字符串进行任意长度前缀交换,然后不断重复这个过程,问在过程中,第一行字符串不同的个数
 3     组合数学题:每一列不同的字母都有可能到第一行,所以每列的可能值相乘取模就行了。这题主要坑在题意理解上。。。
 4 */
 5 #include <cstdio>
 6 #include <algorithm>
 7 #include <cstring>
 8 #include <cmath>
 9 #include <map>
10 using namespace std;
11 
12 typedef long long ll;
13 const int MAXN = 1e2 + 10;
14 const int INF = 0x3f3f3f3f;
15 const int MOD = 1e9 + 7;
16 char s[MAXN][MAXN];
17 int a[MAXN];
18 map<char, int> cnt[MAXN];
19 
20 int main(void)        //Codeforces Round #108 (Div. 2) C. Pocket Book
21 {
22 //    freopen ("D.in", "r", stdin);
23 
24     int n, m;
25     while (scanf ("%d%d", &n, &m) == 2)
26     {
27         memset (a, 0, sizeof (a));
28         for (int i=1; i<=m; ++i)    cnt[i].clear ();
29         scanf ("%s", s[1] + 1);
30         for (int i=2; i<=n; ++i)
31         {
32             scanf ("%s", s[i] + 1);
33         }
34 
35         for (int j=1; j<=m; ++j)
36         {
37             for (int i=1; i<=n; ++i)
38             {
39                 if (cnt[j][s[i][j]] == 0)
40                 {
41                     cnt[j][s[i][j]] = 1;    a[j]++;
42                 }
43             }
44         }
45 
46         ll ans = 1;
47         for (int i=1; i<=m; ++i)
48         {
49             ans = (ans * a[i]) % MOD;
50         }
51         printf ("%I64d\n", ans);
52     }
53 
54     return 0;
55 }

 

组合数学题 Codeforces Round #108 (Div. 2) C. Pocket Book

标签:

原文地址:http://www.cnblogs.com/Running-Time/p/4656720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!