CodeForce 677C - Vanya and Label

Vanya and Label

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

题意:

  给出字符串转化为数字,问有多少个 位 & 还是原来的数字

思路:

  把这些字符转化成数字后变成2进制,看有多少个0,如果有n个0,那么就是3的n次方;  因为每一个为0的位置上可以有0&1,1&0,0&0,这3种情况,最后结果就是3的n次方了,快速幂

AC代码:
# include <iostream>
using namespace std;
const int mod = 1e9+7;
string s;
int f(char ch)
{
    if(ch >= ‘0‘ && ch <= ‘9‘)
		return ch - ‘0‘;
    else if(ch >= ‘A‘ && ch <= ‘Z‘)
		return ch-‘A‘+10;
    else if(ch >= ‘a‘ && ch <= ‘z‘)
		return ch - ‘a‘ + 36;
    else if(ch == ‘-‘)
		return 62;
    else if(ch == ‘_‘)
		return 63;
}
int main()
{
    cin >> s;
    long long ans = 1;
    for(int i = 0; i < s.size();i++)
    {
        int t = f(s[i]);
        for(int j = 0; j < 6; j++)
            if(!((t >> j) & 1 ))
				ans = ans * 3 % mod;
    }
    cout << ans << endl;
}

 
时间: 2024-10-12 14:15:29

CodeForce 677C - Vanya and Label的相关文章

CodeForce 677B Vanya and Food Processor

 Vanya and Food Processor Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k cen

Codeforces Round #355 (Div. 2) Vanya and Label

这道题很注重转化,其实质其实是将字符串每个字符转换成对应的数字后,按照6位进行二进制转化,然后统计0出现的次数,0&1=0,1&0=1,0&0=0,有些人用了快速幂,实际上这完全没有必要,但是一定要用long long. #include <iostream> #include <cstdio> #include <string> using namespace std; const long long MOD=1e9+7; string s;

codeforce 677D Vanya and Treasure

原题地址:http://codeforces.com/problemset/problem/677/D 题意 略 题解 直接的DP是n2m2的复杂度,据题解说通过bfs来转移可以实现n*m*sqrt(n*m)…… #include<bits/stdc++.h> #define clr(x,y) memset((x),(y),sizeof(x)) using namespace std; typedef long long LL; const int maxn=300; struct Cood

codeforces 的20道C题

A - Warrior and Archer CodeForces - 595C n  偶数  然后n个数字 A B 轮流取一个 A让差变小B让差变大 直到最后2 个   求的是最小剩下的差 最后剩下的 L R  相距 n/2    求一下最小的就行 #include <iostream> #include <cstdio> #include <cmath> #include <map> #include <algorithm> #include

#C++初学记录(ACM8-6-cf-f题)

F. Vanya and Label 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 st

关于label和input对齐的那些事

input文本和label对齐 默认状态下,也就是下面这样, 文字和input是居中的. <div>     <label>我是中国人</label>     <input type="text"></div> 但是经常设计图中有label的行高,或者input的高度设计,默认状态下,依然是居中的.但是很多时候label和input要浮动,一旦浮动,后面的input标签就紧紧的贴住了label标签,也就造成了视觉上看到并没有居

微信小程序组件解读和分析:十一、label标签

label标签组件说明: label标签,与html的label标签基本一样.label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label 元素内点击文本,就会触发此控件.就是说,当用户选择该标签时,就会自动将焦点转到和标签绑定的表单控件上,主要用来改进表单组件的可用性.使用for属性找到对应的id,或者将控件放在该标签下,当点击时,就会触发对应的控件.for优先级高于内部控件,内部有多个控件的时候默认触发第一个控件.目前可以绑定的控件有:<button/>

Tkinter,label内容随多选框变化

当我们改变一个组件后,其他组件一起变化怎么做呢?下面是一个例子 from tkinter import Tk, Checkbutton, Label from tkinter import StringVar, IntVar root = Tk() text = StringVar() text.set('old') status = IntVar() def change(): if status.get() == 1:   # if clicked text.set('new') else:

jquery点击label触发2次的问题

今天写问卷的时候遇到个label点击的时候,监听的click事件被执行两次:产生这个的原因么...事件冒泡 <div class="questionBox checkBox"> <div class="title"> 2.你如何理解创新意识的重要性?</div> <div class="checkBoxList" data-more="2"> <label> <