Codeforces Round #355 (Div. 2) C 预处理
1 second
256 megabytes
standard input
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.
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 '_'.
Print a single integer — the number of possible pairs of words, such that their bitwise AND is equal to string s modulo 109 + 7.
z
3
V_V
9
Codeforces
130653412
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:
- z&_ = 61&63 = 61 = z
- _&z = 63&61 = 61 = z
- 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 预处理的更多相关文章
- Codeforces Round #355 (Div. 2)-C
C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Va ...
- Codeforces Round #355 (Div. 2)-B
B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...
- Codeforces Round #355 (Div. 2)-A
A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
- E. Vanya and Balloons Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...
- D. Vanya and Treasure Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- JQuery实现父级选择器(广告实现)
效果图如下: HTML代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- MySQL5.6基于MHA方式高可用搭建
master 10.205.22.185 #MHA node slave1 10.205.22.186 #MHA node+MHA manager slave2 10.205.22.187 #MH ...
- axios进行ajax请求得不到数据,cookie无法携带问题
这个坑也是很早之前踩过,今天做项目的时候居然忘了,怎么都拿不到数据,果然好记性不如烂笔头,决定写篇博客来祭奠下我的猪脑子: 原因可能就是你发送请求的时候,需要设置cookie,然而你的cookie并没 ...
- Spark提交任务(Standalone和Yarn)
Spark Standalone模式提交任务 Cluster模式: ./spark-submit \--master spark://node01:7077 \--deploy-mode clus ...
- linuxC编程介绍
第一步:写完程序 /first.c/ #include <stdio.h> int main() { printf("hello,welcome to the LinuxC!\n ...
- Leetcode 337. 打家劫舍 III
题目链接 https://leetcode.com/problems/house-robber-iii/description/ 题目描述 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可 ...
- 初见spark-03(高级算子)
最近心情不是很好,但是需要调节自己,真的需要调节自己,还是要努力,这个世界有我喜欢的人,有我追求的人,也许真的是守的住寂寞,耐得住繁华吧. 不说别的了,今天我们来接受啊spark的高级算子的系列 1. ...
- 树莓派Raspberry Pi 3安装步骤
一.需要的硬件 1.Raspberry Pi 3(Model B+)树莓派.购买>https://item.jd.com/29225467867.html 2.输出5V/2A的电源 3.SD卡( ...
- quartz 动态更改执行时间
说明:Quartz + Servlet, 参考国外著名站点的文章:http://stackoverflow.com/questions/12208309/need-to-set-the-quartz- ...
- C#中窗体、MDI的使用心得
1、Show()和ShowDialog()的差别,前者在执行之后,无需等待返回,多用于MDI窗体的显示(MDI窗体之间是并列的,可以随时切换,需要注意自己调整的页面的需求,是要并列,还是要等待其中一个 ...