code forces 152C Pocket Book
来源:互联网 发布:借贷管理系统源码 编辑:程序博客网 时间:2024/05/21 04:44
One day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly m letters long. Let's number the names from 1 to n in the order in which they are written.
As mom wasn't home, Vasya decided to play with names: he chose three integers i, j, k (1 ≤ i < j ≤ n, 1 ≤ k ≤ m), then he took names number i and j and swapped their prefixes of length k. For example, if we take names "CBDAD" and "AABRD" and swap their prefixes with the length of 3, the result will be names "AABAD" and "CBDRD".
You wonder how many different names Vasya can write instead of name number 1, if Vasya is allowed to perform any number of the described actions. As Vasya performs each action, he chooses numbers i, j, k independently from the previous moves and his choice is based entirely on his will. The sought number can be very large, so you should only find it modulo 1000000007 (109 + 7).
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of names and the length of each name, correspondingly. Then n lines contain names, each name consists of exactly m uppercase Latin letters.
Print the single number — the number of different names that could end up in position number 1 in the pocket book after the applying the procedures described above. Print the number modulo 1000000007 (109 + 7).
2 3AABBAA
4
4 5ABABABCGDGAAAAAYABSA
216
In the first sample Vasya can get the following names in the position number 1: "AAB", "AAA", "BAA" and "BAB".
【题解】
就简单的组合问题。每一列元素的种类数之积即为答案。
【AC代码】
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>using namespace std;typedef long long ll;const int inf = 1e9+7;const int N=110;ll vis[N];char str[N][N];int main(){ ll ans,x,y; while(~scanf("%lld%lld",&x,&y)) { getchar(); ans=1; for(int i=0;i<x;++i) gets(str[i]); for(int i=0;i<y;++i) { ll num=0; memset(vis,0,sizeof vis); for(int j=0;j<x;++j) { if(vis[str[j][i]-'0']==0) { vis[str[j][i]-'0']=1; num++; } } ans = ans*num%inf; } printf("%lld\n",ans); } return 0;}
- code forces 152C Pocket Book
- CodeForces 152C Pocket Book
- Codeforces 152C Pocket Book 思维
- Codeforce-152C-Pocket Book(排列组合+思维)
- Code Forces #5C
- Code forces 612C
- CodeForces 152C Pocket Book(找规律+哈希)
- code forces 370C. Mittens
- code forces 401C Team
- Code Forces 26C Dijkstra?
- Code forces 612C-----栈
- Code forces 200C---Football Championship
- Code Forces 369 C 深搜,图
- Code forces 376 C Divisible by Seven
- code forces 405C Unusual Product
- Code Forces 298 C Polycarpus' Dice
- Code Forces 469C 24 Game
- Code Forces 525C Ilya and Sticks
- 如何利用树莓派打造一款机器人
- 明天,这样的嵌入式工程师将秒杀普通程序员?
- iOS开发UI篇—Quartz2D(六) 图片水印,裁剪圆边框,屏幕截图 图片截屏 图片擦除
- 雷布斯来西雅图了,小伙伴们快去求偶遇啊!
- 实现 RecyclerView 上拉加载及自动加载
- code forces 152C Pocket Book
- EOJ 3452- 唐纳德先生和假骰子
- 推荐两款简单好用的扒站工具
- 算法的封装与切换——策略模式(一)
- PrefixHeader.pch添加头文件报错
- 自己不知道的
- Redux状态管理 2.Redux如何和React一起使用
- 深入浅出 Java 8 Lambda 表达式
- JVM垃圾回收机制