[暴力枚举]Codeforces Vanya and Label
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
题意:给你一个字符串s,把字符映射为一些数字,问有多少对和这个字符串长度相同的字符串逐位AND得到仍能得到字符串s
思路:看每位有多少种可能,再把他们相乘并取模,就是答案,注意到最多只有64个字符,所以O(n*n)暴力,4096*1e5大概在4e8可以在一秒内跑完
#include<bits/stdc++.h>
using namespace std;
const int amn=1e5+,mod=1e9+;
char a[amn];
int main(){
ios::sync_with_stdio();
cin>>a;
long long ans=,sum;
int len=strlen(a),in,jg;
for(int i=;i<len;i++){
if(a[i]>=''&&a[i]<='')in=a[i]-'';
else if(a[i]>='A'&&a[i]<='Z')in=a[i]-'A'+;
else if(a[i]>='a'&&a[i]<='z')in=a[i]-'a'+;
else if(a[i]=='-')in=;
else in=;
sum=;
for(int j=;j<=;j++){
for(int k=;k<=;k++){
jg=j&k;
if(jg==in)sum++;
}
}
ans=((ans%mod)*(sum%mod))%mod;
}
printf("%lld\n",ans);
}
/***
给你一个字符串s,把字符映射为一些数字,问有多少对和这个字符串长度相同的字符串逐位AND得到仍能得到字符串s
看每位有多少种可能,再把他们相乘并取模,就是答案,注意到最多只有64个字符,所以O(n*n)暴力,4096*1e5大概在4e8可以在一秒内跑完
***/
最新文章
- myeclicps开发web时候复制一个工程改名字后执行出现404错误
- JS/JQ常见兼容辅助插件
- Android 弹出对话框Dialog充满屏幕宽度
- uva 816 abbott&#39;s revenge ——yhx
- CentOS6.6系统源代码安装mysql5.5.28教程(附源码包下载地址)+sysbench的安装
- Oracle ->;>; 查看分区表的每个分区的数据行分布情况
- ubuntu texlive 中文的配置方法
- 初遇.net
- 通过Nutch扩展点开发插件(添加自定义索引字段到solr)
- 需掌握 - JAVA算法编程题50题及答案
- C# DynamicObject 动态对象
- win10 adb(Android Debug Bridge)导出日志
- supervisor详解
- 2018 USP Try-outsF - Optimizing Transportation in Portugal
- 自定义注解与validation结合使用案例
- 微信小程序实例源码大全2
- Python下图片的高斯模糊化的优化
- 【C#】string格式的日期转为DateTime类型及时间格式化处理方法
- git常用命令简集
- C# 之程序退出的方法
热门文章
- 安装NSQ
- AngularJS入门篇
- 京东Y事业部打造一体化质量管理平台
- Android编程权威指南(第2版)--第16章 使用intent拍照 挑战练习
- JSON parse error: Cannot deserialize value of type `java.util.Date` from String
- python通用读取vcf文件的类(可以直接复制粘贴使用)
- Docker+Cmd+Cli+Git之前端工程化纪要(一)整体目标
- 关于Newtonsoft.Json引用报错
- django之初建项目
- js案例之使用正则表达式进行验证数据正确性