C. Vanya and Label

题目连接:

http://www.codeforces.com/contest/677/problem/C

Description

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.

Sample Input

Codeforces

Sample Output

130653412

Hint

题意

给你一个字符串,问你有多少对相同长度的字符串 & 起来之后,恰好等于这个字符串

这个字符串的每个字符都是代表着0-63之间的数字

题解:

首先每个字符是独立的,我们把每个字符的方案数知道,然后再全部乘起来就好了

0-63是 2^6,那么我们就按位去考虑就好了

如果对于这一位是0的话,那么就有3种方案0&1,1&0,0&0,如果这一位为1的话,只有一种方案

所以看一共有多少个位是0就好了,然后3的那么多次幂就行了

代码

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
string s;
int getidx(char c)
{
if(c>='0'&&c<='9')return c-'0';
if(c>='A'&&c<='Z')return c-'A'+10;
if(c>='a'&&c<='z')return c-'a'+36;
if(c=='-')return 62;
if(c=='_')return 63;
}
int main()
{
cin>>s;
long long ans = 1;
for(int i=0;i<s.size();i++)
{
int p = getidx(s[i]);
for(int j=0;j<6;j++)
if(!((p>>j)&1))
ans=ans*3%mod;
}
cout<<ans<<endl;
}

Codeforces Round #355 (Div. 2) C. Vanya and Label 水题的更多相关文章

  1. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

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

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

  3. Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题

    D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...

  4. Codeforces Round #280 (Div. 2) A. Vanya and Cubes 水题

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

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

  7. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  8. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  9. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

随机推荐

  1. 用C代码简要模拟实现一下RPC(远程过程调用)并谈谈它在代码调测中的重要应用【转】

    转自:http://blog.csdn.net/stpeace/article/details/44947925 版权声明:本文为博主原创文章,转载时请务必注明本文地址, 禁止用于任何商业用途, 否则 ...

  2. awk的常用内置函数的使用【转】

    手把手教你在linux下熟悉使用awk的指令结构 (15) 大家好,今天和大家说一下awk吧.反正正则 早晚也要和大家说,不如一点一点和大家先交代清楚了,省得以后和大家说的时候,大家有懵的感觉... ...

  3. redis学习笔记之redis简介

    redis简介 Redis是一个开源的,高性能的,基于键值对的缓存与存储系统,通过设置各种键值数据类型来适应不同场景下的缓存与存储需求.同事redis的诸多高层级功能使其可以胜任消息队列,任务队列等不 ...

  4. [NOI2014]购票 「树上斜率优化」

    首先易得方程,且经过变换有 $$\begin{aligned} f_i &= \min\limits_{dist_i - lim_i \le dist_j} \{f_j + (dist_i - ...

  5. No.2 selenium学习之路之八种基本定位

    selenium的八种定位方式 1.通过id定位     find_element_by_id() send_keys() 输入框输入字符串 click()  鼠标点击事件 注:send_keys输入 ...

  6. angular可自定义的对话框,弹窗指令

    指令不明的,推荐 AngularJS指令参数详解 github地址 以下为示例代码 <!DOCTYPE html> <html lang="en" ng-app= ...

  7. SQL Server日期计算

    通常,你需要获得当前日期和计算一些其他的日期,例如,你的程序可能需要判断一个月的第一天或者最后一天.你们大部分人大概都知道怎样把日期进行分割(年.月.日等),然后仅仅用分割出来的年.月.日等放在几个函 ...

  8. CVE-2013-0025

    Microsoft IE ‘SLayoutRun’释放后重用漏洞(CNNVD-201302-197) Microsoft Internet Explorer是微软Windows操作系统中默认捆绑的WE ...

  9. MP3 Fuzz学习

    这篇文章主要是学习一波MP3格式fuzz的知识.目录如下 0x0.MP3格式的构成 0x0.MP3格式的构成 MP3是一种通俗叫法,学名叫MPEG1 Layer-3.MP3是三段式的结构,依次由ID3 ...

  10. ETL工具kettle基本使用

    1.下载kettle:https://sourceforge.net/projects/pentaho/files/Data%20Integration/7.0/pdi-ce-7.0.0.0-25.z ...