Codeforces Round #355 (Div. 2)-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.
 
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 '_'.
Print a single integer — the number of possible pairs of words, such that their bitwise AND is equal to string s modulo109 + 7.
z
3
V_V
9
Codeforces
130653412
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:
- z&_ = 61&63 = 61 = z
 - _&z = 63&61 = 61 = z
 - 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的更多相关文章
- Codeforces Round #355 (Div. 2)-B
		
B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...
 - Codeforces Round #355 (Div. 2)-A
		
A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...
 - Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
		
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
 - E. Vanya and Balloons Codeforces Round #355 (Div. 2)
		
http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...
 - D. Vanya and Treasure Codeforces Round #355 (Div. 2)
		
http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...
 - 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 ...
 - 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 ...
 - 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 ...
 - 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 ...
 
随机推荐
- log4net使用
			
平时项目里一直都有在使用log4net作为日志记录模块,当时一直都没有去理解log4net的配置文件信息.今天抽出了一点时间来看了看配置文件信息. log4net配置文件信息: <log4net ...
 - codeforces   515B. Drazil and His Happy Friends   解题报告
			
题目链接:http://codeforces.com/problemset/problem/515/B 题目意思:有 n 个 boy 和 m 个 girl,有 b 个 boy 和 g 个 girl ( ...
 - mybatis 的if else
			
<update id="update" parameterType="XXX"> update XX set YY ...
 - python getopt.getopt 不能精确匹配的问题
			
代码:opts,argv = getopt.getopt(sys.argv[1:],('u:'),['ad','join','passwd=','domain=','dip=','test','ip= ...
 - 更新补丁Bind
			
1.查询补丁版本信息 (1) rpm -qa|grep bind (2) dig @localhost version.bind 2.下载安装 BIND最新漏洞和升级解决办法 现在有非常多的公司的都有 ...
 - Android笔记:实现点击事件
			
布局文件声明控件 .java文件获取控件 1. button.setOnClickListener(new View.OnClickListener() { @Override ...
 - mongoose学习笔记1--基础知识1
			
今天我们将学习Mongoose,什么是Mongoose呢,它于MongoDB又是什么关系呢,它可以用来做什么呢? MongoDB是一个开源的NoSQL数据库,相比MySQL那样的关系型数据库,它更显得 ...
 - 备忘zookeeper(单机+伪集群+集群)
			
#下载: #单机模式 解压到合适目录. 进入zookeeper目录下的conf子目录, 复制zoo_sample.cfg-->zoo.cfg(如果没有data和logs就新建):tickTime ...
 - Java 回调机制的理解
			
// 在接口中声明一个处理耗时操作结果的回调方法. // Local 实现这个接口,实现处理耗时操作结果的回调方法. // Local 获得 Remote 对象,在子线程中调用 Remote 的处理耗 ...
 - eclipse使用时jar不在libraries
			
jar是在项目工程的目录下 点击工程右键 这样jar包边收到librarles中