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

题目传送门

 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 }
时间: 2024-11-05 14:54:59

组合数学题 Codeforces Round #108 (Div. 2) C. Pocket Book的相关文章

Codeforces Round #108 (Div. 2)——状态压缩DP+spfa+dfs——Garden

Vasya has a very beautiful country garden that can be represented as an n × m rectangular field divided into n·m squares. One beautiful day Vasya remembered that he needs to pave roads between k important squares that contain buildings. To pave a roa

Codeforces Round #261 (Div. 2) 459B. Pashmak and Flowers(数学题,组合)

题目链接:http://codeforces.com/problemset/problem/459/B B. Pashmak and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak decided to give Parmida a pair of flowers from the garden.

Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak has fallen in love with an attractive girl called Parmida s

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o

Codeforces Round #258 (Div. 2) A. Game With Sticks(数学题)

题目链接:http://codeforces.com/contest/451/problem/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

CodeCraft-19 and Codeforces Round #537 (Div. 2) - D. Destroy the Colony(动态规划+组合数学)

Problem  CodeCraft-19 and Codeforces Round #537 (Div. 2) - D. Destroy the Colony Time Limit: 2000 mSec Problem Description Input Output For each question output the number of arrangements possible modulo 10^9+7. Sample Input abba21 41 2 Sample Output

Codeforces Round #259 (Div. 2) 解题报告

终于重上DIV1了.... A:在正方形中输出一个菱形 解题代码: 1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2014年08月01日 星期五 23时27分55秒 4 5 #include<vector> 6 #include<set> 7 #include<deque> 8 #include<stack> 9 #include<bitset> 10 #inclu

Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟

E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to

Codeforces Round #354 (Div. 2) ABCD

Codeforces Round #354 (Div. 2) Problems # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393 D T