zoukankan      html  css  js  c++  java
  • Codeforces 152C:Pocket Book(思维)

    http://codeforces.com/problemset/problem/152/C

    题意:给出n条长度为m的字符串,对于第一条字符串的每个位置利用第2~n条字符串的相应位置的字符去替换相应的位置,问能构造出多少种字符串。

    思路:因为每个能交换的位置是固定的,所以交换之后那个位置始终由在那个位置的字符组成。那么假设第i个位置可以取x种字符,第j个位置可以取y种字符,那么它们构造出的字符串的种类为x*y种,以此类推,最后的数目是等于每个位置的字符的种数相乘。

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <set>
     4 using namespace std;
     5 const int MOD = 1e9 + 7;
     6 set<char> st[105];
     7 char s[105][105];
     8 int main() {
     9     int n, m;
    10     scanf("%d%d", &n, &m);
    11     for(int i = 0; i < n; i++) scanf("%s", s[i]);
    12     for(int i = 0; i < m; i++)
    13         for(int j = 0; j < n; j++)
    14             st[i].insert(s[j][i]);
    15     long long ans = 1;
    16     for(int i = 0; i < m; i++)
    17         ans = ans * st[i].size() % MOD;
    18     printf("%lld
    ", ans % MOD);
    19     return 0;
    20 }
  • 相关阅读:
    工科物理实验()中国大学MOOC答案(已更新)
    类似jar文件使用java无法打开问题
    python9、10章
    nmap的理解与利用(初级)
    常见端口
    配置优化
    删除表操作
    万能的map
    测试
    Mapper.xml
  • 原文地址:https://www.cnblogs.com/fightfordream/p/6388101.html
Copyright © 2011-2022 走看看