题目链接:

C. 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
z
output
3
input
V_V
output
9
input
Codeforces
output
130653412

题意:

每一位用这些字符来代替,问有多少对与s相同长度的字符串的&运算之后等于s;

思路:

把这些字符转化成数字后变成2进制,看有多少个0,如果有n个0,那么就是3的n次方;
因为每一个为0的位置上可以有0&1,1&0,0&0,这3种情况,最后结果就是3的n次方了,快速幂; AC代码:
#include <bits/stdc++.h>
/*#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
*/
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e10;
const int N=1e5+;
char s[N];
int check(int x)
{
if(s[x]>=''&&s[x]<='')return s[x]-'';
else if(s[x]>='a'&&s[x]<='z')return s[x]-'a'+;
else if(s[x]>='A'&&s[x]<='Z')return s[x]-'A'+;
else if(s[x]=='-')return ;
else if(s[x]=='_')return ;
}
int fun(int x)
{
int num=;
int cnt=;
while(cnt--)
{
if(x%==)num++;
x=(x>>);
}
return num;
}
LL fastpow(int y)
{
LL ans=,base=;
while(y)
{
if(y&)
{
ans=ans*base;
ans%=mod;
}
base=base*base;
base%=mod;
y=(y>>);
}
return ans;
} int main()
{
scanf("%s",s);
int len=strlen(s);
int sum=;
for(int i=;i<len;i++)
{
int x=check(i);
sum=sum+fun(x);
}
print(fastpow(sum));
return ;
}


最新文章

  1. slf4j
  2. Cytoscape.js – 用于数据分析和可视化的交互图形库
  3. sql语句获取今天、昨天、近7天、本周、上周、本月、上月、半年数据
  4. yii2.0高级框架配置时打开init.bat秒退的解决方法 (两种方法)
  5. 【Cocos2d-Js基础教学(5)资源打包工具的使用及资源的异步加载处理】
  6. PHP模拟发送POST请求之四、加强file_get_contents()发送POST请求
  7. SQL server 性能调优
  8. 在PowerDesigner中设计物理模型2——约束
  9. 那传说中的P、NP以及NPC问题
  10. python操作redis-set
  11. jQuery的入门与简介
  12. aspx基础开始
  13. JAVA基础-IO流(二)
  14. 【Unity3D技术文档翻译】第1.7篇 AssetBundles 补丁更新
  15. 【UML 建模】在线UML建模工具 ProcessOn 使用详解
  16. linux自动备份lampp的日志
  17. 使用signalr实现网页和微信公众号实时聊天(上)
  18. Zend 无限试用
  19. RESTframework简介
  20. ASP.NET 之 EntityFramework实体框架搭建

热门文章

  1. 无责任Windows Azure SDK .NET开发入门篇一[Windows Azure开发前准备工作]
  2. Log设计
  3. Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口
  4. 转载:DIV+CSS有可能遇到的问题
  5. 【转】Android开发实践:自定义带消息循环(Looper)的工作线程
  6. 终于可以发布Delphi下收点OSGI精髓皮毛而设计的插件框架WisdomPluginFramework
  7. UE 的使用
  8. Swift学习笔记九
  9. PS-添加前景色
  10. Codeforces Gym 100463D Evil DFS