题目链接:http://codeforces.com/contest/677/problem/C

题意:给一个字符和数字的映射关系,然后再给一个字符串。问有多少个其他的字符串,使得那些字符串之间相互操作:每一个字符相与的结果不变。

这题给了一组映射关系,由于只有64个字符,那也就是说明只用到了6个bit位。如果这个字符串中某个字符与另一个字符串的同一位的字符相与结果想要不变,举个例子:

字符串s中有一个字符的数字映射是101010,那对应的字符的结果应当是1X1X1X,X有可能是1&0、0&1、0&0,所以遇到一个X就有三种情况,那么这个例子里有3个X,也就是3^3种情况。推广一下就是有k个X,那就有3^k个。

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rlf(a) scanf("%lf", &a);
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
const int mod = ;
int cv[];
char s[maxn]; int quickmul(int x, int n) {
int ret = , t = x;
while(t) {
if(n & ) ret = (ret * t) % mod;
t = t * t % mod;
n >>= ;
}
return ret;
} int main() {
// FRead();
Rep(i, ) cv[''+i] = i;
For(i, , ) cv['A'+i-] = i;
For(i, , ) cv['a'+i-] = i;
cv['-'] = ; cv['_'] = ;
while(~Rs(s)) {
int n = strlen(s);
LL ret = ;
Rep(i, n) {
int p = cv[s[i]];
int t = - __builtin_popcount(p);
ret = (ret * quickmul(, t)) % mod;
}
printf("I64d\n", ret);
}
RT ;
}

[Codeforces677C]Vanya and Label(组合数学,快速幂)的更多相关文章

  1. codeforces 677C C. Vanya and Label(组合数学+快速幂)

    题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...

  2. hdu 5363 组合数学 快速幂

    Time Limit: 2000/1000 MS (Java/Others)   Memory Limit: 131072/131072 K (Java/Others) Problem Descrip ...

  3. UVA 11609 Teams 组合数学+快速幂

    In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...

  4. BZOJ_1008_[HNOI2008]_越狱_(简单组合数学+快速幂)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1008 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰 ...

  5. ACM学习历程—SNNUOJ 1116 A Simple Problem(递推 && 逆元 && 组合数学 && 快速幂)(2015陕西省大学生程序设计竞赛K题)

    Description Assuming a finite – radius “ball” which is on an N dimension is cut with a “knife” of N- ...

  6. 【BZOJ1008】1008: [HNOI2008]越狱 简单组合数学+快速幂

    Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 In ...

  7. poj 3734 Blocks 快速幂+费马小定理+组合数学

    题目链接 题意:有一排砖,可以染红蓝绿黄四种不同的颜色,要求红和绿两种颜色砖的个数都是偶数,问一共有多少种方案,结果对10007取余. 题解:刚看这道题第一感觉是组合数学,正向推了一会还没等推出来队友 ...

  8. CCF 201312-4 有趣的数 (数位DP, 状压DP, 组合数学+暴力枚举, 推公式, 矩阵快速幂)

    问题描述 我们把一个数称为有趣的,当且仅当: 1. 它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次. 2. 所有的0都出现在所有的1之前,而所有的2都出现在所有的3之前. 3. 最高 ...

  9. BZOJ_1005_ [HNOI2008]_明明的烦恼_(组合数学+purfer_sequence+高精度+分解因数+快速幂)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1005 一棵树有n个点,给出没给节点的度,如果没有限制则为-1,求共有多少种可能的树. 分析 蒟 ...

随机推荐

  1. Notes of the scrum meeting(10/31)

    meeting time:3:00~4:30p.m.,October 30th,2013 meeting place:绿园 attendees: 顾育豪                        ...

  2. UVA 10954 Add All 哈夫曼编码

    题目链接: 题目 Add All Time Limit:3000MS Memory Limit:0KB 问题描述 Yup!! The problem name reflects your task; ...

  3. 【UVA】【10828】随机程序

    数学期望/高斯消元/马尔可夫过程 刘汝佳老师白书上的例题- -b 本体不满足拓扑关系,但马尔可夫过程是可以高斯消元解的…… 用「高斯·约当消元」更方便! //UVA 10828 #include< ...

  4. 【BZOJ】【1385】【Baltic2000】Division expression

    欧几里得算法 普通的求个gcd即可……思路题 因为要求尽量是整数……所以 $\frac{x_1}{x_2*x_3*x_4*....*x_n}$是最大的结果了,因为$x_2$必须为分母,$x_1$必须为 ...

  5. [BC]BestCoder Round#86小结

    1001 [题意] 给定一个长度为n(n<=100000)的正整数序列,给出m(m<=100000)个子集合和的记录,问哪些一定比正确的记录多了 [题解] 对正整数序列求和,记录比和大的一 ...

  6. Unsupervised Learning: Use Cases

    Unsupervised Learning: Use Cases Contents Visualization K-Means Clustering Transfer Learning K-Neare ...

  7. PHP对XML文件操作类讲解

    <?phpclass XML{    private $dom;        function __construct ()    {        $this->dom = new D ...

  8. PHP读取xml方法讲解

    一,什么是xml,xml有什么用途 XML(Extensible Markup Language)即可扩展标记语言,它与HTML一样,都是SGML(Standard Generalized Marku ...

  9. 为什么乱码:<meta http-equiv="content-type">前的非ANSI字符

    为什么乱码:<meta http-equiv="content-type">前的非ANSI字符 浏览器检测网页字符集的默认顺序 浏览器的网页字符集检测顺序通常是: ch ...

  10. 解决unity3d发布的网页游戏放到服务器上无法使用的问题

    http://www.unity蛮牛.com/blog-2429-1226.html 第一次把unity3d发布的网页游戏放到服务器上(Win2003),发现无法使用.可以尝试以下办法.       ...