CodeForces 677C Vanya and Label

C. Vanya and Label

      time limit per test    1 second

      memory limit per test    256 megabytes

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

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

AC代码

#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
map<char,int> m;
//int n,h,k;
int a[100010],c[7][7];
int sum=0, b[64];
int C(int a,int b){
	for(int i=0;i<=a;i++){
		c[i][0]=1;
		c[i][i]=1;
	}
	for(int i=2;i<=a;i++){
		for(int j=1;j<i;j++){
			c[i][j]=c[i-1][j-1]+c[i-1][j];
		}
	}
}
int main(){
	C(6,6);
	for(int i=0;i<64;i++){
		int j=i;
		int num=0;
		while(j){
			if(j%2) num++; 
			j/=2;
		}
		//b[i]=pow(2,6-num+1)-1;
		for(int j=0; j <= 6-num; j++){
			b[i]+=c[6-num][j]*pow(2,j);
		}
		//cout<<b[i]<<' ';
	}
	//cout<<endl;
	
	int tot=0;
	for(char c='0';c<='9';c++){
		m[c]=tot++;
	}
	for(char c='A';c<='Z';c++){
		m[c]=tot++;
	}
	for(char c='a';c<='z';c++){
		m[c]=tot++;
	}
	m['-']=tot++;
	m['_']=tot++;
	string s;
	cin>>s; 
	long long ans=1;
	//cout<<m['z']<<endl; 
	for(int i=0;i<s.length();i++){
		ans=ans*(b[m[s[i]]]%Mod);
		ans%=Mod;
	}
	ans%=Mod;
	cout<<ans<<endl;
}
发布了46 篇原创文章 · 获赞 81 · 访问量 5562

猜你喜欢

转载自blog.csdn.net/zfq17796515982/article/details/88095305