[Codeforces677C]Vanya and Label(组合数学,快速幂)
2016-06-03 13:33
351 查看
题目链接:http://codeforces.com/contest/677/problem/C
题意:给一个字符和数字的映射关系,然后再给一个字符串。问有多少个其他的字符串,使得那些字符串之间相互操作:每一个字符相与的结果不变。
这题给了一组映射关系,由于只有64个字符,那也就是说明只用到了6个bit位。如果这个字符串中某个字符与另一个字符串的同一位的字符相与结果想要不变,举个例子:
字符串s中有一个字符的数字映射是101010,那对应的字符的结果应当是1X1X1X,X有可能是1&0、0&1、0&0,所以遇到一个X就有三种情况,那么这个例子里有3个X,也就是3^3种情况。推广一下就是有k个X,那就有3^k个。
题意:给一个字符和数字的映射关系,然后再给一个字符串。问有多少个其他的字符串,使得那些字符串之间相互操作:每一个字符相与的结果不变。
这题给了一组映射关系,由于只有64个字符,那也就是说明只用到了6个bit位。如果这个字符串中某个字符与另一个字符串的同一位的字符相与结果想要不变,举个例子:
字符串s中有一个字符的数字映射是101010,那对应的字符的结果应当是1X1X1X,X有可能是1&0、0&1、0&0,所以遇到一个X就有三种情况,那么这个例子里有3个X,也就是3^3种情况。推广一下就是有k个X,那就有3^k个。
/* ━━━━━┒ギリギリ♂ eye! ┓┏┓┏┓┃キリキリ♂ mind! ┛┗┛┗┛┃\○/ ┓┏┓┏┓┃ / ┛┗┛┗┛┃ノ) ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┃┃┃┃┃┃ ┻┻┻┻┻┻ */ #include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <climits> #include <complex> #include <fstream> #include <cassert> #include <cstdio> #include <bitset> #include <vector> #include <deque> #include <queue> #include <stack> #include <ctime> #include <set> #include <map> #include <cmath> using namespace std; #define fr first #define sc second #define cl clear #define BUG puts("here!!!") #define W(a) while(a--) #define pb(a) push_back(a) #define Rlf(a) scanf("%lf", &a); #define Rint(a) scanf("%d", &a) #define Rll(a) scanf("%I64d", &a) #define Rs(a) scanf("%s", a) #define Cin(a) cin >> a #define FRead() freopen("in", "r", stdin) #define FWrite() freopen("out", "w", stdout) #define Rep(i, len) for(int i = 0; i < (len); i++) #define For(i, a, len) for(int i = (a); i < (len); i++) #define Cls(a) memset((a), 0, sizeof(a)) #define Clr(a, x) memset((a), (x), sizeof(a)) #define Full(a) memset((a), 0x7f7f, sizeof(a)) #define lrt rt << 1 #define rrt rt << 1 | 1 #define pi 3.14159265359 #define RT return #define lowbit(x) x & (-x) #define onenum(x) __builtin_popcount(x) typedef long long LL; typedef long double LD; typedef unsigned long long ULL; typedef pair<int, int> pii; typedef pair<string, int> psi; typedef map<string, int> msi; typedef vector<int> vi; typedef vector<LL> vl; typedef vector<vl> vvl; typedef vector<bool> vb; const int maxn = 100100; const int mod = 1000000007; int cv[256]; char s[maxn]; int quickmul(int x, int n) { int ret = 1, t = x; while(t) { if(n & 1) ret = (ret * t) % mod; t = t * t % mod; n >>= 1; } return ret; } int main() { // FRead(); Rep(i, 10) cv['0'+i] = i; For(i, 10, 36) cv['A'+i-10] = i; For(i, 36, 62) cv['a'+i-36] = i; cv['-'] = 62; cv['_'] = 63; while(~Rs(s)) { int n = strlen(s); LL ret = 1; Rep(i, n) { int p = cv[s[i]]; int t = 6 - __builtin_popcount(p); ret = (ret * quickmul(3, t)) % mod; } printf("I64d\n", ret); } RT 0; }
相关文章推荐
- Linux navite过期
- Java实现Excel导入数据库,数据库中的数据导入到Excel
- poj 3278 bfs 标记数组
- Python编程规范
- 数据库常用操作
- springmvc集成JSR-303的解析消息文件的默认实现浅析
- PhoneGap中"unable to download archive from the server. "警告的解决方法
- Android 自定义view设置xml属性
- 选择排序和插入排序
- matlab之plot、fplot、ezplot函数
- Android事件传递机制以及ViewGroup的onInterceptTouchEvent的理解
- SQL Server优化50法
- sql语句基础要点(以sql server 2008 为例)
- 如何用#define宏定义多行函数
- Ubuntu16.04 安装flash player
- 低代码平台,到底能给企业带来什么?
- Apache服务器访问权限设置
- js date 操作
- 操作linux redis 常用命令
- iOS多级跳转,返回指定viewcontroller