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

While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string sand wants to know the number of pairs of words of length |s| (length of s), such that their bitwise AND is equal to s. As this number can be large, output it modulo 109 + 7.

To represent the string as a number in numeral system with base 64 Vanya uses the following rules:

  • digits from '0' to '9' correspond to integers from 0 to 9;
  • letters from 'A' to 'Z' correspond to integers from 10 to 35;
  • letters from 'a' to 'z' correspond to integers from 36 to 61;
  • letter '-' correspond to integer 62;
  • letter '_' correspond to integer 63.
Input

The only line of the input contains a single word s (1 ≤ |s| ≤ 100 000), consisting of digits, lowercase and uppercase English letters, characters '-' and '_'.

Output

Print a single integer — the number of possible pairs of words, such that their bitwise AND is equal to string s modulo109 + 7.

Examples
input
z
output
3
input
V_V
output
9
input
Codeforces
output
130653412
Note

For a detailed definition of bitwise AND we recommend to take a look in the corresponding article in Wikipedia.

In the first sample, there are 3 possible solutions:

  1. z&_ = 61&63 = 61 = z
  2. _&z = 63&61 = 61 = z
  3. z&z = 61&61 = 61 = z

题意:给定一个字符串,每个字符定义如上说明。然后问有多少长度和给定的串长度相同并且与给定的串位与之后还是等于给定的串。 输出结果MOD 1e9+7

思路:考虑每个字符,因为有位于运算所以先把字符对应的数字转换为二进制,可以发现0-63只需6位二进制表示。然后考虑每一位i[0-5],如果该位为1,那么要使得&后与原串相同,那么对应该位置只能1[1&1=1], 但是如果该位为0,那么对应位置就可以是0&0,0&1,1&0共3种。最后根据组合乘法计算总数。

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<bitset>
using namespace std;
typedef long long int LL;
#define INF 0x3f3f3f3f
const int MAXN = + ;
const int MOD = 1e9 + ;
char str[MAXN];
int getnum(char ch){
int num;
if (ch >= ''&&ch <= ''){
num = ch - '';
}
else if (ch >= 'A'&&ch <= 'Z'){
num = (ch - 'A') + ;
}
else if (ch >= 'a'&&ch <= 'z'){
num = (ch - 'a') + ;
}
else if (ch == '-'){
num = ;
}
else{
num = ;
}
return num;
}
LL powmod(LL x, LL n){
LL ans = ;
while (n){
if (n & ){
ans = (ans*x)%MOD;
}
x = (x*x)%MOD;
n >>= ;
}
return ans;
}
int main(){
while (~scanf("%s", str)){
LL ans = ; int len = strlen(str);
for (int i = ; i < len; i++){
bitset<> num(getnum(str[i]));
for (int j = ; j < ; j++){
if (num[j] == ){
ans++;
}
}
}
printf("%I64d\n", powmod(,ans)%MOD);
}
return ;
}

Codeforces Round #355 (Div. 2)-C的更多相关文章

  1. Codeforces Round #355 (Div. 2)-B

    B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...

  2. Codeforces Round #355 (Div. 2)-A

    A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...

  3. Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块

    题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...

  4. E. Vanya and Balloons Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...

  5. D. Vanya and Treasure Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...

  6. Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力

    D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...

  7. Codeforces Round #355 (Div. 2) C. Vanya and Label 水题

    C. Vanya and Label 题目连接: http://www.codeforces.com/contest/677/problem/C Description While walking d ...

  8. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  9. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

随机推荐

  1. SQL键值约束、索引使用

    添加約束的方式: [exec sp_helpconstraint 表名]->可用于查找到表创建的约束 CREATE TABLE stuInfo ( stuName ) NOT NULL,非空約束 ...

  2. linux下修改tomcat内存大小

    转载自:http://blog.sina.com.cn/s/blog_7fb5109d0101o49a.html 1.  出现此问题的原因:       在tomcat中发布了多个webapp引用,每 ...

  3. andriod一次退出所有的Activity

    自己实现了一个Activity管理,可以实现一次退出所有的Activity.在Activity启动的时候,将调用里面的put方法,将Activity对象加入进来.在要退出某个activity的时候,将 ...

  4. 【XLL API 函数】 xlDefineBinaryName

    用于为 xltypeBigData XLOPER/XLOPER12 分配永久存储名称.用于定义 workbook 保存的位名称,并能在任何时候通过定义名称来访问. 函数原型 Excel12(xlDef ...

  5. [Android Pro] 小心ReleaseByteArrayElements 中的参数问题

    referen to : http://blog.csdn.net/rainlight/article/details/818964 在Sun的官方文档中,关于该函数的用法如下 The array i ...

  6. centOS填坑笔记(一)

    第一次使用centOS安装软件时,对二进制包的./configure进行配置时(./configure是源代码安装的第一步,主要的作用是对即将安装的软件进行配置,)报错:WARNING: failed ...

  7. Ubuntu(Linux)使用Eclipse搭建C/C++编译环境

    转自:http://www.cppblog.com/kangnixi/archive/2010/02/10/107636.html 首先是安装Eclipse,方法有两种:       第一种是通过Ub ...

  8. 模拟赛1102d2

    /* φ(n)=φ(p^k)=p^k-p^(k-1)=(p-1)*p^(k-1) φ(m*n)=φ(m)*φ(n) 直接套公式做,因为分解质因数时,只分解一个数,所以可以不打素数表,只将n分解到√n就 ...

  9. sp_who使用

    [SQL Server]  sp_who, sp_who2和sp_who3 sp_who可以返回如下信息: (可选参数LoginName, 或active代表活动会话数)Spid         (系 ...

  10. history 清空历史记录 或 history不记录历史命令

    # vi ~/.bash_history 清空里面的记录,并退出当前shell # exit(一定要退出当前shell) # history 1 vi ~/.bash_history 2 histor ...