码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-06-07 01:13:15      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

这道题很注重转化,其实质其实是将字符串每个字符转换成对应的数字后,按照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;

int GetNum(char ch)
{
	if(ch>=‘0‘&&ch<=‘9‘)
		return ch-‘0‘;
	if(ch>=‘A‘&&ch<=‘Z‘)
		return ch-‘A‘+10;
	if(ch>=‘a‘&&ch<=‘z‘)
		return ch-‘a‘+36;
	if(ch==‘-‘)
		return 62;
	if(ch=‘_‘)
		return 63;
}

long long ans=1;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int tag=GetNum(s[i]);
		int cnt=0;
		for(int j=0;j<6;j++)
		{
			if(!(tag&1))
				cnt++;
			tag>>=1;
		}
		for(int i=1;i<=cnt;i++)
			ans=ans*3%MOD;
	}
	printf("%I64d\n",ans);
	return 0;
}

  

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

标签:

原文地址:http://www.cnblogs.com/northsnow95/p/5565573.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!