Codeforces Round #355 (Div. 2) C. Vanya and Label 水题
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 水题的更多相关文章
- 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 ...
- Codeforces Round #355 (Div. 2)C - Vanya and Label
啊啊啊啊啊啊啊,真的是智障了... 这种题目,没有必要纠结来源.只要知道它的结果的导致直接原因?反正这句话就我听的懂吧... ">>"/"&" ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
随机推荐
- go 指针类型
变量和内存地址 每个变量都有内存地址,可以说通过变量来操作对应大小的内存 var a int32 a = fmt.Printf(“%d\n”, a) fmt.Printf(“%p\n”, &a ...
- 个性化你的Git Log的输出格式
git已经变成了很多程序员日常工具之一. git log是查看git历史的好工具,不过默认的格式并不是特别的直观. 很多时候想要更简便的输出更多或者更少的信息,这里列出几个git log的format ...
- WCF ServiceContract,OperationContract
代码如下 [ServiceContract] //服务协定定义 using System.ServiceModel; public interface IInterface1 { [Operation ...
- Team Foundation Server 2010服务器安装
本安装指南使用Windows Server 2008企业版为基础,安装Windows Server 2008 SP2(必须),在此操作系统环境上进行TFS2010的安装与配置. 三.系统用户设置 1. ...
- Golang实现mysql读库映射成Map【Easy】
这个类库灵感来源于.net的dbHelper类,因为其简单易用,现在go的driver必须使用对象映射,这让人火大不爽,不能实现灵活的Map,在Key经常变动的业务场景里面非常不爽,我还是喜欢直接写s ...
- Elasticsearch 邻近查询示例
Elasticsearch 邻近查询示例(全切分分词) JAVA API方式: SpanNearQueryBuilder span = QueryBuilders.spanNearQuery(); s ...
- 开启nginx目录文件列表功能
ngx_http_autoindex_module 此模块用于自动生成目录列表,ngx_http_autoindex_module只在 ngx_http_index_module模块未找到索引文件时 ...
- R vs Python:载入包 import & library
数据科学:R & Python 工作 & Kaggle机器学习比赛 可重复函数式编程 一.Python模块的载入 包 Package 模块 module import pandas a ...
- How to tell your iPhone application that location services are required | The Agile Warrior
div{padding-bottom:10px}.b_vPanel>div:last-child{padding:0}.banner a{color:#1020d0} --> Below ...
- Asis CTF 2015-Car_Market
恰好找到了这道题的bin文件,就来做一下. 这道题目是一个经典的选单程序但是具有三级选单,在bss段存在指针数组ptr,ptr中的值指向每个主结构,其中主结构如下所示. [] model [] pri ...