Vanya and Label
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.
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.

Examples
input

Copy
z
output

Copy
3
input

Copy
V_V
output

Copy
9
input

Copy
Codeforces
output

Copy
130653412
Note

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:

  1. z&_ = 61&63 = 61 = z
  2. _&z = 63&61 = 61 = z
  3. 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可以在一秒内跑完
***/

[暴力枚举]Codeforces Vanya and Label的更多相关文章

  1. Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举

    题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...

  2. codeforces 677C C. Vanya and Label(组合数学+快速幂)

    题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. Codeforces 677C. Vanya and Label 位操作

    C. Vanya and Label time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  4. 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 ...

  5. Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举

    B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ...

  6. 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 ...

  7. Codeforces 425A Sereja and Swaps(暴力枚举)

    题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ...

  8. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  9. D. Diverse Garland Codeforces Round #535 (Div. 3) 暴力枚举+贪心

    D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard i ...

随机推荐

  1. 手工创建 efi,msr 分区 · Virgil Chan

    昨天在帮同学装 win10 的时候,不小心(不知道那是什么东西)把原系统的 efi 和 msr 盘删了,用 WinNTsetup 安装时 EFI PART 总显示红叉,安装后也进不去系统,想想应该是找 ...

  2. GLPI 0.85.5 上传漏洞分析

    在exp-db上面看到的漏洞,这是原文链接:https://www.exploit-db.com/exploits/38407/ 但是POC给的很简单,这是原来的描述: " The appl ...

  3. Nginx设置目录浏览并配置验证

    Nginx默认是不允许进行列目录的,如果需要使某个目录可以进行浏览,可如下设置:如: 让/var/www/soft 这个目录在浏览器中完成列出. 一.设置目录浏览1.打开/usr/local/ngin ...

  4. linux tc流量控制

    tc流量控制 项目背景 vintage3.0接口lookupforupdage增加一个策略,当带宽流量tx或rx超过40%,75%随机返回304:超过60%,此接口均返回304 为了对测试机器进行流量 ...

  5. 成长日记(2) Java面向对象

    本篇主要是记录自己在学习路上的笔记,如果有哪里记错了请大家直接指出 面向对象的概念 *人为抽象的一种编程模型 *面向过程 代码集中 难以维护 *类:对事物 算法 逻辑 概念等的抽象 理解成 模板 图纸 ...

  6. Ubuntu gnome 美化与个别组件安装

    1. 安装 gnome 工具 sudo apt install gnome-tweaks# 打开时中文直接选择 "优化" 即可 1.1. gnome 官网 # https://ex ...

  7. 有了这个开源 Java 项目,开发出炫酷的小游戏好像不难?

    本文适合有 Java 基础知识的人群,跟着本文可学习和运行 Java 的游戏. 本文作者:HelloGitHub-秦人 HelloGitHub 推出的<讲解开源项目>系列,今天给大家带来一 ...

  8. Python基础--动态传参

    形参的顺序: 位置 *arg     默认值  **args  ps:可以随便搭配,但是*和**以及默认值的位置顺序不能变 *,** 形参:聚合 位置参数* >>元祖 关键字** > ...

  9. 微信小程序转化为uni-app项目

    前言: 之前自己做一个uni-app的项目的时候前端需要实现一个比较复杂的功能,但是由于自己前端抠脚的原因没有写出来,然后自己在网上搜索的时候发现了有个微信小程序里面的页面及其的符合我的需求.那么问题 ...

  10. 必备技能一、webpack

    https://cloud.tencent.com/developer/section/1477376----->配置很重要 一.基本安装 mkdir webpack-demo &&am ...