C. Vanya and Label
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

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 s and 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 modulo 109 + 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
 
传送门:http://codeforces.com/contest/677/problem/C

题意:一个字符串s,字符串的每个字母代表一种数字。问多少种的等长的字符串通过&操作得到s。

思路:1&0=0,0&1=0,0&0=0,1&1=1。字符串里面的每一个字符ch的每一位与1 &操作,如果得到0就有3就情况,如果得到1只有一种情况。[0,63]的2进制最多有6位。

代码:

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+;
char s[];
int getidx(char c)
{
if(c>=''&&c<='') return c-'';
if(c>='A'&&c<='Z') return c-'A'+;
if(c>='a'&&c<='z') return c-'a'+;
if(c=='-') return ;
if(c=='_') return ;
}
int main()
{
int i,j;
scanf("%s",s);
__int64 ans = ;
for(i=; i<strlen(s); i++)
{
int p = getidx(s[i]);
for(j=; j<; j++)
if(((p>>j)&)==) ans=ans*%mod;
}
cout<<ans<<endl;
}

位操作

Codeforces 677C. 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. 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 ...

  3. codeforces 355 div2 C. Vanya and Label 水题

    C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. [暴力枚举]Codeforces Vanya and Label

    Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  5. codeforces 492E. Vanya and Field(exgcd求逆元)

    题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走 ...

  6. Codeforces 677D Vanya and Treasure 暴力+BFS

    链接 Codeforces 677D Vanya and Treasure 题意 n*m中有p个type,经过了任意一个 type=i 的各自才能打开 type=i+1 的钥匙,最初有type=1的钥 ...

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

    啊啊啊啊啊啊啊,真的是智障了... 这种题目,没有必要纠结来源.只要知道它的结果的导致直接原因?反正这句话就我听的懂吧... ">>"/"&" ...

  8. 暑假练习赛 006 E Vanya and Label(数学)

    Vanya and LabelCrawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB    ...

  9. CodeForces 552C Vanya and Scales

    Vanya and Scales Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. [Python] numpy.random.rand

    numpy.random.rand numpy.random.rand(d0, d1, ..., dn) Random values in a given shape. Create an array ...

  2. 从最大似然函数 到 EM算法详解

    极大似然算法 本来打算把别人讲的好的博文放在上面的,但是感觉那个适合看着玩,我看过之后感觉懂了,然后实际应用就不会了.... MLP其实就是用来求模型参数的,核心就是“模型已知,求取参数”,模型的意思 ...

  3. tensorflow读取数据

    线程和队列 在使用TensorFlow进行异步计算时,队列是一种强大的机制. 为了感受一下队列,让我们来看一个简单的例子.我们先创建一个“先入先出”的队列(FIFOQueue),并将其内部所有元素初始 ...

  4. yii 日期插件

    ——controller     public $defaultAction = "income";    public function actionIncome(){      ...

  5. Selenium Webdriver——操作隐藏的元素

    有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...

  6. HTML5 Canvas ( 线性渐变, 升级版的星空 ) fillStyle, createLinearGradient, addColorStop

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. left join 如何增加where条件(在on的后面),这很重要

    SELECT [学号], [姓名],[备注2],[年级],专业,[学院],[x30] FROM [总表] left join k指标体系  on  学号 = x01 where 年级='2014'

  8. Spring boot Tomcat配置

    来自: https://www.cnblogs.com/a8457013/p/7687764.html

  9. 使用java代码执行linux命令

    前提: java代码是在windows下面写的,要打包放到linux下面运行,并且执行某个脚本. java代码: try { // 起作用的代码其实就下面这一行, 参数是linux中要执行的代码 Ru ...

  10. Apache Hive 执行HQL语句报错 ( 10G )

    # 故障描述: hive > , ) as uuid, count(distinct(request_body["uuid"])) as count from log_bft ...