给你一个字符串,问你有多少对相同长度的字符串 & 起来之后,恰好等于这个字符串,这个字符串的每个字符都是代表着0-63之间的数字。
'0'~'9'代表数字0~9
'A'~'Z'代表数字10~35
'a'~'z'代表数字36~61
'-'代表62
'_' 代表63
Input
输入一个字符串s,长度小于等于1e5,大于等于1
Output
输出答案,答案模1e9+7
Examples
Input
z
Output
3
Input
V_V
Output
9
Input
Codeforces
Output
130653412
Note
- z&_ = 61&63 = 61 = z
- _&z = 63&61 = 61 = z
- z&z = 61&61 = 61 = z
题意:
给出字符串转化为数字,问有多少个 位 & 还是原来的数字
思路:
把这些字符转化成数字后变成2进制,看有多少个0,如果有n个0,那么就是3的n次方;
因为每一个为0的位置上可以有0&1,1&0,0&0,这3种情况,最后结果就是3的n次方了,快速幂
#include<iostream> #include<algorithm> #include<map> using namespace std; typedef long long ll; const ll mod=1e9+7; map<char,int>mp; void inint(){ for(int i=0;i<=9;i++){ mp[i+'0']=i; } for(int i=10;i<=35;i++){ mp[i-10+'A']=i; } for(int i=36;i<=61;i++){ mp[i-36+'a']=i; } mp['-']=62; mp['_']=63; } int main(){ inint(); string a; cin>>a; ll ans=1; for(int i=0;i<a.size();i++){ int p=mp[a[i]]; for(int j=0;j<6;j++){ if(!((p>>j)&1)){ ans=(ans*3)%mod; } } } printf("%lld ",ans%mod); }