Codeforces 677C. Vanya and Label 位操作
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
题意:一个字符串s,字符串的每个字母代表一种数字。问多少种的等长的字符串通过&操作得到s。
思路:1&0=0,0&1=0,0&0=0,1&1=1。字符串里面的每一个字符ch的每一位与1 &操作,如果得到0就有3就情况,如果得到1只有一种情况。[0,63]的2进制最多有6位。
代码:
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+;
char s[];
int getidx(char c)
{
if(c>=''&&c<='') return c-'';
if(c>='A'&&c<='Z') return c-'A'+;
if(c>='a'&&c<='z') return c-'a'+;
if(c=='-') return ;
if(c=='_') return ;
}
int main()
{
int i,j;
scanf("%s",s);
__int64 ans = ;
for(i=; i<strlen(s); i++)
{
int p = getidx(s[i]);
for(j=; j<; j++)
if(((p>>j)&)==) ans=ans*%mod;
}
cout<<ans<<endl;
}
位操作
Codeforces 677C. Vanya and Label 位操作的更多相关文章
- codeforces 677C C. Vanya and Label(组合数学+快速幂)
题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 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 355 div2 C. Vanya and Label 水题
C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- [暴力枚举]Codeforces Vanya and Label
Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 492E. Vanya and Field(exgcd求逆元)
题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走 ...
- Codeforces 677D Vanya and Treasure 暴力+BFS
链接 Codeforces 677D Vanya and Treasure 题意 n*m中有p个type,经过了任意一个 type=i 的各自才能打开 type=i+1 的钥匙,最初有type=1的钥 ...
- Codeforces Round #355 (Div. 2)C - Vanya and Label
啊啊啊啊啊啊啊,真的是智障了... 这种题目,没有必要纠结来源.只要知道它的结果的导致直接原因?反正这句话就我听的懂吧... ">>"/"&" ...
- 暑假练习赛 006 E Vanya and Label(数学)
Vanya and LabelCrawling in process... Crawling failed Time Limit:1000MS Memory Limit:262144KB ...
- CodeForces 552C Vanya and Scales
Vanya and Scales Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- 【转载】全栈工程师-Hadoop, HBase, Hive, Spark
学习参考这篇文章: http://www.shareditor.com/blogshow/?blogId=96 机器学习.数据挖掘等各种大数据处理都离不开各种开源分布式系统, hadoop用于分布式存 ...
- 1.scrapyd部署相关问题
部署scrapy爬虫项目到6800上 启动scrapyd 出现问题 1: scrapyd-deloy -l 未找到相关命令 scrapyd-deploy -l 可以看到当前部署的爬虫项目,但是当我输 ...
- JAVA SpringMVC + FormDate + Vue + file表单 ( 实现 js 单文件和多文件上传 )
JS 部分 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...
- myeclipse 保存失败
Save FailedCompilation unit name must end with .java, or one of the registered Java-like extensions ...
- 使用Teleport Ultra批量克隆网站,使用Easy CHM合并生成chm文件
1.要下载的页面 http://www.howsoftworks.net/javaapi/ 2. 下载Teleport Ultra 3.使用Teleport Ultra批量克隆网站 4.下载Easy ...
- 可视化库-seaborn-Facetgrid(第五天)
1. sns.Facetgrid 画一个基本的直方图 import numpy as np import pandas as pd from scipy import stats, integrate ...
- UI5-文档-4.3-Controls
现在是时候构建我们的第一个小UI了,将HTML主体中的“Hello World”文本替换为SAPUI5控件sap.m.Text.首先,我们将使用JavaScript控件接口来设置UI,然后将控件实例放 ...
- ubuntu 安装u盘恢复
XP下进入CMD命令窗体,Vista及7/8下右键以管理员方式运行DOS窗体(win8.1:开始屏幕-windows系统-命令提示符) 输入DISKPART,会显示计算机名,及DISKPART> ...
- Word 2003-在一个方框里打勾或打叉
最近有个同事问我,如何在Word中输出一个方框中打勾的符号?查了一下帮助,其实很简单,特记录如下,供碰到的朋友参考: 一.在方框中打勾的方法: 先输入一个大写字母R,然后将R选中,将字体改为“Wind ...
- MySql重复查询
MYSQL查询重复记录的方法很多,下面就为您介绍几种最常用的MYSQL查询重复记录的方法,希望对您学习MYSQL查询重复记录方面能有所帮助. 1.查找表中多余的重复记录,重复记录是根据单个字段(peo ...