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可以在一秒内跑完
***/

[暴力枚举]Codeforces Vanya and Label的更多相关文章

  1. Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举

    题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...

  2. codeforces 677C C. Vanya and Label(组合数学+快速幂)

    题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. Codeforces 677C. Vanya and Label 位操作

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

  4. 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 ...

  5. Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举

    B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ...

  6. 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 ...

  7. Codeforces 425A Sereja and Swaps(暴力枚举)

    题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ...

  8. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  9. D. Diverse Garland Codeforces Round #535 (Div. 3) 暴力枚举+贪心

    D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard i ...

随机推荐

  1. Android中Intent的各种常见作用。

    Android开发之Intent.Action  1 Intent.ACTION_MAIN String: android.intent.action.MAIN 标识Activity为一个程序的开始. ...

  2. Oracle最大进程连接数问题

    问题描述 分析报告保存功能,在本地测试使用时可以正常保存:但是部署在客户现场的系统该功能无法保存成功(全部保存): ---->代码功能没有问题,问题应该在服务器配置或者数据库配置等方面出现问题: ...

  3. 初学qt——提示窗体

    带选择的窗体 QMessageBox::StandardButton rb = QMessageBox::critical(NULL, QString::fromLocal8Bit("提示& ...

  4. java基础进阶篇(四)_HashMap------【java源码栈】

    目录 一.前言 二.特点和常见问题 二.接口定义 三.初始化构造函数 四.HashMap内部结构 五.HashMap的存储分析 六.HashMap的读取分析 七.常用方法 八.HashMap 的jav ...

  5. echart 新手踩坑

    仪表盘踩坑 我采用的是单文件引入的方式来加载echarts图标也可以使用配置等方式详情参考文档,如果同学们要做出更加丰富的样式请参考文档配置手册配置手册:http://echarts.baidu.co ...

  6. EventEmitter:从命令式 JavaScript class 到声明函数式的华丽转身

    新书终于截稿,今天稍有空闲,为大家奉献一篇关于 JavaScript 语言风格的文章,主角是函数声明式. 灵活的 JavaScript 及其 multiparadigm 相信"函数式&quo ...

  7. Visual Studio Code打开后是黑色的什么都没显示

    测试系统:win7 x64. 问题:打开Microsoft VS Code后是黑色的界面并且什么都没有显示. 截图:本来想放一张图片的,因为当时忘记截了,所以这里就忽略了. 解决办法: 需要安装以下三 ...

  8. python之路-基本数据类型之str字符串

    1.概念 python中用',",''',"""引起来的内容称为字符串,可以保存少量数据并进行相应的操作 #先来看看str的源码写了什么,方法:按ctrl+鼠标 ...

  9. Flutter保持页面状态AutomaticKeepAliveClientMixin

    使用bottomNavigationBar切换底部tab,再切换回来就会丢失之前的状态(重新渲染列表,丢失滚动条位置). 解决方法 使用 AutomaticKeepAliveClientMixin 重 ...

  10. 内网渗透之信息收集-Linux系统篇

    linux 系统信息 grep MenTotal /proc/meminfo #查看系统内存总量 cat /etc/issue #查看系统名称 cat /etc/lsb-release #查看系统名称 ...