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

题意:不同字符表示0~63   给你一个字符串判断 有多少对 长度相同的字符串的 &运算的结果 为所给的字符串

题解:模拟

1&1=1   0&1=0  1&0=0  0&0=0

打表预处理 0~63的满足情况的对数

例如31=(11111)2

共有三对    111111&011111

011111&111111

011111&011111

结果乘积并取模

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#define ll __int64
#define pi acos(-1.0)
#define mod 1000000007
using namespace std;
map<char,int> mp;
ll a[];
char b[];
ll quickmod(ll a,ll b)
{
ll sum=;
while(b)
{
if(b&)
sum=(sum*a%mod);
b>>=;
a=(a*a%mod);
}
return sum;
}
void init ()
{
for(int i=;i<=;i++)
{
int n=i;
int c=;
while (n >)
{
if((n &) ==)
++c ;
n >>= ;
}
a[i]=quickmod(,-c);
}
int jishu=;
for(int i='';i<='';i++)
{
mp[i]=a[jishu];
jishu++;
}
for(int i='A';i<='Z';i++)
{
mp[i]=a[jishu];
jishu++;
}
for(int i='a';i<='z';i++)
{
mp[i]=a[jishu];
jishu++;
}
mp['-']=a[];
mp['_']=a[];
}
int main()
{
init();
ll ans=;
scanf("%s",b);
int len=strlen(b);
for(int i=;i<len;i++)
ans=(ans%mod*mp[b[i]])%mod;
cout<<ans<<endl;
return ;
}

Codeforces Round #355 (Div. 2) C 预处理的更多相关文章

  1. Codeforces Round #355 (Div. 2)-C

    C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Va ...

  2. Codeforces Round #355 (Div. 2)-B

    B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...

  3. Codeforces Round #355 (Div. 2)-A

    A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...

  4. Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块

    题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...

  5. E. Vanya and Balloons Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...

  6. D. Vanya and Treasure Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...

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

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

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

随机推荐

  1. 文件权限管理命令chmod,chown与文本搜索命令grep

    1.复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限. [root@bogon home]# cp -r /etc/sk ...

  2. 封装动态数组类Array

    功能: 1.增.删.改.查 2.扩容.缩容 3.复杂度分析 4.均摊复杂度 5.复杂度震荡 分析动态数组的时间复杂度: 分析resize的时间复杂度: public class Array<E& ...

  3. css样式 body的font-size 为什么用625%

    浏览器的默认高度?一般为16px. 为什么用62.5%作为body的默认样式?16px62.5%=10px.* 那么为什么一般多是 16px  *625% = 100px; <响应式Web设计实 ...

  4. strak组件(5):为列表定制预留钩子方法

    效果图:  新增函数 def get_list_display(self): 获取页面上应该显示的列,预留的自定义扩展,例如:以后根据用户的不同显示不同的 一.stark组件 stark/servic ...

  5. python, 面向对象编程Object Oriented Programming(OOP)

    把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数. 面向过程的程序设计把计算机程序视为一系列的命令集合,即一组函数的顺序执行.为了简化程序设计,面向过程把函数继续切分为子函数,即把大块函数 ...

  6. Matplotlib库介绍

    pyplot的plot()函数 pyplot的中文显示 pyplot的文本显示 pyplot的子绘图区域

  7. 邮件系统之Postfix与Dovecot

    电子邮件系统 电子邮件系统基于邮件协议来完成电子邮件的传输,常见的邮件协议有: 简单邮件传输协议(Simple Mail Transfer Protocol,SMTP):用于发送和中转发出的电子邮件, ...

  8. Android面试收集录14 Android进程间通信方式

    一.使用 Intent Activity,Service,Receiver 都支持在 Intent 中传递 Bundle 数据,而 Bundle 实现了 Parcelable 接口,可以在不同的进程间 ...

  9. Kotlin 二分法算法游戏--猜价格

    本人最新想学习算法,算法是提高程序性能的关键! 程序就是数据结构和算法! 写了一个二分法的游戏,供大家参考: 当然,语言基于kotlin import java.util.* /** * Create ...

  10. Erlang OTP设计原则Gen_Fsm行为[转]

    转自: http://www.cnblogs.com/yourihua/archive/2012/05/13/2497776.html 1. Fsm 称为 有限状态机,举个例子,游戏中的怪物称为NPC ...