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 ...
随机推荐
- poj1056
简单题 #include <iostream> #include <string> using namespace std; struct cnode { cnode *pze ...
- 签名DLL
签名DLL 首先需要一个密钥文件,后缀为.snk 密钥文件使用sn.exe 创建: sn.exe /k MySingInKey.snk sn.exe 工具的具体使用,可以通过 sn.exe /h 或 ...
- 汇编看C函数调用
http://blog.csdn.net/wishfly/article/details/5022008 简单的函数调用,通过简单的函数调用反汇编可以清楚了解如下 1.栈到底是什么,如何操纵栈的? ...
- OutLook中添加Exchange失败问题
问题: 在邮件中添加账户后,打开outlook时报出错误:无法启动 Microsoft Outlook. 无法打开 Outlook 窗口. 无法打开此文件夹集合. 必须先使用当前的配置文件连接到 Mi ...
- 最邻近规则分类KNN算法
例子: 求未知电影属于什么类型: 算法介绍: 步骤: 为了判断未知实例的类别,以所有已知类别的实例作为参照 选择参数K 计算未知实例与所有已知实例的距离 选择最近K个已 ...
- android拾遗——Android之Notification和NotificationManager
1.使用系统自带的Notification //创建一个NotificationManager的引用 String ns = Context.NOTIFICATION_SERVICE; Notific ...
- CCF CSP 201709-2 公共钥匙盒
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201709-2 公共钥匙盒 问题描述 有一个学校的老师共用N个教室,按照规定,所有的钥匙都必须 ...
- python 库资源大全
偶然的机会翻到这篇文章,很全面,来源: Python 资源大全中文版 哪些 Python 库让你相见恨晚? 环境管理 管理 Python 版本和环境的工具 p:非常简单的交互式 pyth ...
- 基于Json.NET自己实现MVC中的JsonValueProviderFactory
写了博文ASP.NET MVC 3升级至MVC 5.1的遭遇:“已添加了具有相同键的项”之后,继续看着System.Web.Mvc.JsonValueProviderFactory的开源代码. 越看越 ...
- 自建YUM源以及相关维护
yum相关概念我这里就不做详细的讲解了,就是一个软件包管理工具.在企业中,很多时候进行编译了自己的RPM包,在搭建YUM的时候,希望将自定义的RPM加入到YUM源中,从而出现了下列方法. 一.配置私有 ...