Codeforces Round #355 (Div. 2) C

Description

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  

给我们一下字符串,问我们可以通过&后,值依然和题目上规定的相同

我们当然可以先把0~63的先全部&一下,存下结果,然后,就一个字符一个字符的判断就好啦~

复制代码
 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<map>
 4 using namespace std;
 5 map<int,int> q;
 6 int main()
 7 {
 8     for(int i=0;i<=63;i++)
 9     {
10         for(int j=0;j<=63;j++)
11         {
12             q[i&j]++;
13         }
14     }
15     int pos;
16     long long num=1;
17     string s;
18     cin>>s;
19     for(int i=0;i<s.length();i++)
20     {
21         if(s[i]>='0'&&s[i]<='9')
22         {
23             pos=s[i]-'0';
24         }
25         else if(s[i]>='A'&&s[i]<='Z')
26         {
27             pos=s[i]-'A'+10;
28         }
29         else if(s[i]>='a'&&s[i]<='z')
30         {
31             pos=s[i]-'a'+36;
32         }
33         else if(s[i]=='-')
34         {
35             pos=62;
36         }
37         else if(s[i]=='_')
38         {
39             pos=63;
40         }
41         num=num*q[pos]%1000000007;
42     }
43     cout<<num<<endl;
44     return 0;
45 }
复制代码

 

posted @   樱花落舞  阅读(340)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示