C - Pocket Book(set)
Problem description
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).
Input
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.
Output
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).
Examples
Input
2 3
AAB
BAA
Output
4
Input
4 5
ABABA
BCGDG
AAAAA
YABSA
Output
216
Note
In the first sample Vasya can get the following names in the position number 1: "AAB", "AAA", "BAA" and "BAB".
解题思路:找规律。输入n个字符串,每个字符串的长度都为m,可以将其看成是二维数组。只要将每一列中不同字符的个数相乘起来,最终即为所求答案。注意:要用long long避免数据溢出,水过。
AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+;
int main()
{
int n,m;LL sum=;
set<char> se[];string obj[];
cin>>n>>m;getchar();
for(int i=;i<n;++i)cin>>obj[i];
for(int i=;i<n;++i)
for(int j=;j<m;++j)
se[j].insert(obj[i][j]);
for(int i=;i<m;++i)
sum=(sum*se[i].size())%mod;
cout<<sum<<endl;
return ;
}
C - Pocket Book(set)的更多相关文章
- Codeforces 152C:Pocket Book(思维)
http://codeforces.com/problemset/problem/152/C 题意:给出n条长度为m的字符串,对于第一条字符串的每个位置利用第2~n条字符串的相应位置的字符去替换相应的 ...
- CSS3与页面布局学习总结(一)——概要、选择器、特殊性与刻度单位
web前端开发者最最注的内容是三个:HTML.CSS与JavaScript,他们分别在不同方面发挥自己的作用,HTML实现页面结构,CSS完成页面的表现与风格,JavaScript实现一些客户端的功能 ...
- 推荐几款我一直在用的chrome插件(下)
请先看:推荐几款我一直在用的chrome插件(上) 6. Pocket 可以很方便的保存文章.视频等供以后查看,即实现了“Read it later”功能.有了 Pocket,您可以将所有想下次读的内 ...
- CSS3与页面布局学习笔记(一)——概要、选择器、特殊性与刻度单位
web前端开发者最最注的内容是三个:HTML.CSS与JavaScript,他们分别在不同方面发挥自己的作用,HTML实现页面结构,CSS完成页面的表现与风格,JavaScript实现一些客户端的功能 ...
- GitHub 优秀的 Android 开源项目(转)
今天查找资源时看到的一篇文章,总结了很多实用资源,十分感谢原作者分享. 转自:http://blog.csdn.net/shulianghan/article/details/18046021 主要介 ...
- QQ 腾讯QQ(简称“QQ”)是腾讯公司开发的一款基于Internet的即时通信(IM)软件
QQ 编辑 腾讯QQ(简称“QQ”)是腾讯公司开发的一款基于Internet的即时通信(IM)软件.腾讯QQ支持在线聊天.视频通话.点对点断点续传文件.共享文件.网络硬盘.自定义面板.QQ邮箱等多种功 ...
- [Programming Entity Framework] 第3章 查询实体数据模型(EDM)(一)
http://www.cnblogs.com/sansi/archive/2012/10/18/2729337.html Programming Entity Framework 第二版翻译索引 你可 ...
- C#开源系统大汇总(转)
一.AOP框架 Encase 是C#编写开发的为.NET平台提供的AOP框架.Encase 独特的提供了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方式.这种 ...
- 线性模型(1):Perceptron Learning Algorithm (PLA)
此笔记源于台湾大学林轩田老师<机器学习基石><机器学习技法> (一) PLA算法是基本的binary Classification算法. 一个基本的问题是,对于银行,假设我知道 ...
随机推荐
- apicloud常用分享方法
app中经常会有分享的功能,不管是分享商品还是文字还是图片或者是发送给微信好友扣扣好友,一下做一总结. 分享的样式(分享所有的样式模块):MNActionButton. 在apicloud 中添加这个 ...
- PAT_A1076#Forwards on Weibo
Source: PAT A1076 Forwards on Weibo (30 分) Description: Weibo is known as the Chinese version of Twi ...
- Pytorch实战(3)----分类
一.分类任务: 将以下两类分开. 创建数据代码: # make fake data n_data = torch.ones(100, 2) x0 = torch.normal(2*n_data, 1) ...
- 在 CentOS 7 上设置 grub2
在 CentOS 7 上设置 grub2 1. 开机选单是自动创建出来的 请勿尝试手动编辑开机选单,因为它是按照 /boot/ 目录内的文件自动创建出来的.然而你可以调整 /etc/default/g ...
- CodeIgniter-CI之MySQL
首先我们需要进行一下配置,这里需要修改的文件为application目录下的config目录下的database.php文件,我们修改相应的配置项,比如这里是我的配置情况: 通常我们在操作数据库之前, ...
- dup、文件锁、库函数、函数调用(day07)
一.lseek()重新定位文件的读写位置. #include <sys/types.h> #include <unistd.h> off_t lseek(int fd, off ...
- BZOJ1001 BJOI2006 狼抓兔子
Description 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的,而且现在的兔子还比较笨,它们只有两个窝,现在你做为狼王,面对下面这样一个 ...
- Linux系统学习之 三:新手必须掌握的Linux命令3
内容预览 1.输入输出重定向 2.管道命令符 3.命令行的通配符 4.常用的转义符号 5.重要的环境变量 一.输入输出重定向 重定向技术的5种模式:1 标准覆盖输出重定向 错误覆盖输出重定向 错误追加 ...
- List集合中把其中一个元素 调整到集合的第一位
要求:现在想把集合中的某个元素,放到该集合的第一个位置,但是其他元素的顺序不需要管. 方法:需要遍历集合,找到这个元素在集合中的位置,然后使用Collections.swap(list,o,i) (O ...
- 【ZOJ 4060】Flippy Sequence
[链接] 我是链接,点我呀:) [题意] [题解] 按照两个区间的排列方式 我们可以分成以下几种情况 会发现这两个区间的作用 最多只能把两段连续不同的区间变为相同. 那么写个for处理出连续不相同的一 ...