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
  1. z
Output
  1. 3
Input
  1. V_V
Output
  1. 9
Input
  1. Codeforces
Output
  1. 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位。

代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int mod = 1e9+;
  4. char s[];
  5. int getidx(char c)
  6. {
  7. if(c>=''&&c<='') return c-'';
  8. if(c>='A'&&c<='Z') return c-'A'+;
  9. if(c>='a'&&c<='z') return c-'a'+;
  10. if(c=='-') return ;
  11. if(c=='_') return ;
  12. }
  13. int main()
  14. {
  15. int i,j;
  16. scanf("%s",s);
  17. __int64 ans = ;
  18. for(i=; i<strlen(s); i++)
  19. {
  20. int p = getidx(s[i]);
  21. for(j=; j<; j++)
  22. if(((p>>j)&)==) ans=ans*%mod;
  23. }
  24. cout<<ans<<endl;
  25. }

位操作

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. CSS3基础知识(一)

    结构选择器 :nth-child(n) 第几个元素 从1开始设置 :nth-child(2n) 偶数元素 从0开始设置 :nth-child(2n+1) 奇数元素 :nth-of-type(n) :f ...

  2. position属性详解

    内容: 1.position属性介绍 2.position属性分类 3.relative相对定位 4.absolute绝对定位 5.relative和absolute联合使用进行定位 6.fixed固 ...

  3. 一,Android Studio笔记

    转自:https://developer.android.com/studio/intro/index.html 一.界面 Android Studio 主窗口由图 3 标注的几个逻辑区域组成. 工具 ...

  4. Mysql-两表的连接,copy表,select的各种用法

    -- 连接:外连接,内连接 两个表之间 外连接:right join    left join -- left join 左标为主 一般以值少的为主 select * from table1 left ...

  5. 表单:checkbox、radio样式(用图片换掉默认样式)

    checkbox.radio样式(用图片换掉默认样式) <!doctype html> <html> <head> <meta charset="u ...

  6. sqlserver主从复制

    参考网站: http://www.178linux.com/9079 https://www.cnblogs.com/tatsuya/p/5025583.html windows系统环境进行主从复制操 ...

  7. JAVA 读取配置文件 xxx.properties

    package config_demo; import java.io.InputStream; import java.util.Properties; public class UrlDemo { ...

  8. 8. mybatis实战教程(mybatis in action)之七:实现mybatis分页(源码下载)

    转自:https://blog.csdn.net/tangruyi1992/article/details/52584012 上 一篇文章里已经讲到了mybatis与spring MVC的集成,并且做 ...

  9. jquery formValidator 表单验证插件, ajax无法传值到后台问题的解决

    今天使用jquery   formValidator-4.0.1 这个插件做表单验证,  前台验证已写好, 准备写ajax验证, 结果无法把值传到后台 .ajaxValidator({ url : & ...

  10. ABAP-ITS Mobile

    ITS Mobile是14年开发EWM项目时用到的技术方案,本文主要记录下ITS Mobile的整个实现过程. 1.ITS Mobile介绍 ITS Mobile:Internet Transacti ...