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

Copy
z
output

Copy
3
input

Copy
V_V
output

Copy
9
input

Copy
Codeforces
output

Copy
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

题意:给你一个字符串s,把字符映射为一些数字,问有多少对和这个字符串长度相同的字符串逐位AND得到仍能得到字符串s

思路:看每位有多少种可能,再把他们相乘并取模,就是答案,注意到最多只有64个字符,所以O(n*n)暴力,4096*1e5大概在4e8可以在一秒内跑完

 #include<bits/stdc++.h>
using namespace std;
const int amn=1e5+,mod=1e9+;
char a[amn];
int main(){
ios::sync_with_stdio();
cin>>a;
long long ans=,sum;
int len=strlen(a),in,jg;
for(int i=;i<len;i++){
if(a[i]>=''&&a[i]<='')in=a[i]-'';
else if(a[i]>='A'&&a[i]<='Z')in=a[i]-'A'+;
else if(a[i]>='a'&&a[i]<='z')in=a[i]-'a'+;
else if(a[i]=='-')in=;
else in=;
sum=;
for(int j=;j<=;j++){
for(int k=;k<=;k++){
jg=j&k;
if(jg==in)sum++;
}
}
ans=((ans%mod)*(sum%mod))%mod;
}
printf("%lld\n",ans);
}
/***
给你一个字符串s,把字符映射为一些数字,问有多少对和这个字符串长度相同的字符串逐位AND得到仍能得到字符串s
看每位有多少种可能,再把他们相乘并取模,就是答案,注意到最多只有64个字符,所以O(n*n)暴力,4096*1e5大概在4e8可以在一秒内跑完
***/

最新文章

  1. myeclicps开发web时候复制一个工程改名字后执行出现404错误
  2. JS/JQ常见兼容辅助插件
  3. Android 弹出对话框Dialog充满屏幕宽度
  4. uva 816 abbott&#39;s revenge ——yhx
  5. CentOS6.6系统源代码安装mysql5.5.28教程(附源码包下载地址)+sysbench的安装
  6. Oracle -&gt;&gt; 查看分区表的每个分区的数据行分布情况
  7. ubuntu texlive 中文的配置方法
  8. 初遇.net
  9. 通过Nutch扩展点开发插件(添加自定义索引字段到solr)
  10. 需掌握 - JAVA算法编程题50题及答案
  11. C# DynamicObject 动态对象
  12. win10 adb(Android Debug Bridge)导出日志
  13. supervisor详解
  14. 2018 USP Try-outsF - Optimizing Transportation in Portugal
  15. 自定义注解与validation结合使用案例
  16. 微信小程序实例源码大全2
  17. Python下图片的高斯模糊化的优化
  18. 【C#】string格式的日期转为DateTime类型及时间格式化处理方法
  19. git常用命令简集
  20. C# 之程序退出的方法

热门文章

  1. 安装NSQ
  2. AngularJS入门篇
  3. 京东Y事业部打造一体化质量管理平台
  4. Android编程权威指南(第2版)--第16章 使用intent拍照 挑战练习
  5. JSON parse error: Cannot deserialize value of type `java.util.Date` from String
  6. python通用读取vcf文件的类(可以直接复制粘贴使用)
  7. Docker+Cmd+Cli+Git之前端工程化纪要(一)整体目标
  8. 关于Newtonsoft.Json引用报错
  9. django之初建项目
  10. js案例之使用正则表达式进行验证数据正确性