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. 前端js模版 预编译工具Tmod js使用入门

    1. 安装node js , 2. 用 npm install -g tmodjs  命令安装tmod 3.了解参数配置 4.运行测试例子->命令窗切换到当前文档位置 --->执行tomd ...

  2. Spring JMS ActiveMQ整合(转)

    转载自:http://my.oschina.net/xiaoxishan/blog/381209#comment-list ActiveMQ学习笔记(四)http://my.oschina.net/x ...

  3. jsp中<!DOCTYPE>标签

    今天写代码时遇到一个问题,定义了如下一个样式: .c_c1:hover td { background-color: #edf5ce;} <tr class="c_c1"&g ...

  4. .Net SqlDbHelper

    using System.Configuration; using System.Data.SqlClient; using System.Data; namespace ExamDAL { clas ...

  5. ASP.NET Ajax 简单实例

    本实例讲解Ajax 调用WCF服务. 1.建立一个网站,并在其中添加一个WCF服务(这里需要选择Ajax-Enabled WCF Service). 2.IDE会自动生成一个SVC文件. 3.服务代码 ...

  6. ios开发函数(数学函数应用)

    今天在计算collectionView存放最小间距的时候用到一函数 " ABS " 顺便就查了一下这些数学函数在代码中的使用.. //----------------------- ...

  7. “无法更新EntitySet“*****”,因为它有一个DefiningQuery,而元素中没有支持当前操作的元素”问题的解决方法

    百思不得其解,最后发现 1:实体中的表必须有主键(数据库中的表必须有主键),如果没有,会有这样的提示 2:主键设置好后,运行还是会出现类似问题,那就一个郁闷 1):方法一:先从EF中删除刚设置主键的模 ...

  8. 打开Genesis设置单位为mm

    打开Genesis界面: 点击Configuration: 可看到只要设置get_def_units的值即可: 打开C:\genesis\sys\config配置文件,在最后一行加入:get_def_ ...

  9. 四、优化及调试--网站优化--Yahoo军规上

    什么是Yahoo军规?即如何提高网站速度的知识. 具体如下: 1.尽量减少HTTP请求个数——须权衡 什么是http请求:从客户端到服务器端的请求消息.包括消息首行中,对资源的请求方法,资源的标识符及 ...

  10. jQuery - 2.jQuery选择器

    1.id 选择器 2.标签选择器 3.类选择器 4.复合选择器 5.层次选择器 JQuery的迭代   JQuery选择器 JQuery选择器用于查找满足条件的元素,比如可以用$("#控件I ...