神坑 1竟然还要取模

在后面填数多好的

 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; return read(x);
} typedef long long LL;
LL f[][][]; LL dp(int n, int p) {
if(!p || (n & )) return ;
memset(f, , sizeof f);
f[][][ % p] = ;
for(int i = ; i < n; i++) {
for(int j = ; j <= i; j++) {
for(int k = ; k < p; k++) {
f[i + ][j][(k << ) % p] += f[i][j][k];
f[i + ][j + ][(k << | ) % p] += f[i][j][k];
}
}
}
return f[n][n / ][];
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif int T = read<int>(), n, k;
for(int cas = ; cas <= T; cas++) {
read(n), read(k);
printf("Case %d: %lld\n", cas, dp(n, k));
} return ;
}

UVa12063 Zeros and Ones的更多相关文章

  1. Trailing Zeros

    Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...

  2. Case of the Zeros and Ones 分类: CF 2015-07-24 11:05 15人阅读 评论(0) 收藏

    A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...

  3. Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题

    A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  4. lintcode :Trailing Zeros 尾部的零

    题目: 尾部的零 设计一个算法,计算出n阶乘中尾部零的个数 样例 11! = 39916800,因此应该返回 2 挑战 O(logN)的时间复杂度 解题: 常用方法: 也许你在编程之美中看到,通过求能 ...

  5. UVa 12063 (DP) Zeros and Ones

    题意: 找出长度为n.0和1个数相等.没有前导0且为k的倍数的二进制数的个数. 分析: 这道题要用动态规划来做. 设dp(zeros, ones, mod)为有zeros个0,ones个1,除以k的余 ...

  6. Codeforces 556A Case of the Zeros and Ones(消除01)

    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Andr ...

  7. A. Case of the Zeros and Ones----解题报告

    A. Case of the Zeros and Ones Description Andrewid the Android is a galaxy-famous detective. In his ...

  8. Case of the Zeros and Ones

    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Andrew ...

  9. 10324 - Zeros and Ones

    Problem N Zeros and Ones Input: standard input Output: standard output Time Limit: 2 seconds Memory ...

随机推荐

  1. 网络基础---OSI 模型与TCP/IP

    一.网络的演进: 1.简单的联接:1960's ------------ 1970's    Host Network 六十至七十年代,网络的概念主要是主机架构的低速串行联接,提供应用程序执行.远程打 ...

  2. 桌面浏览器实现滑动翻页效果(Swiper)

    还是那个号称很炫的B/S展示软件,在液晶屏上展示需要有滑动翻页的效果(在同一页面滑动切换内容,不是切换页面),最后确定使用功能很强大的Swiper类库. 具体优点可参考:http://www.chin ...

  3. python模块学习 hashlib

    一.hashlib概述 涉及加密服务:14. Cryptographic Services 其中 hashlib是涉及安全散列和消息摘要,提供多个不同的加密算法借口,如SHA1.SHA224.SHA2 ...

  4. angularJS的controller之间如何正确的通信

    AngularJS中的controller是个函数,用来向视图的作用域($scope)添加额外的功能,我们用它来给作用域对象设置初始状态,并添加自定义行为. 当我们在创建新的控制器时,angularJ ...

  5. javascript 一串DIV跟随鼠标移动

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  6. wordpress4.0.1源码学习和摘录--函数

    1.根据类型获取当前时间 function current_time( $type, $gmt = 0 ) { switch ( $type ) { case 'mysql': return ( $g ...

  7. 【python】【转】 for 循环一列

    Python for in循环 来源 http://c.biancheng.net/cpp/html/1822.html   for..in语句是另一个循环语句,它迭代一个对象的序列,例如经历序列中的 ...

  8. 为什么selenium定位不到元素

    在做web应用的自动化测试时,定位元素是必不可少的,这个过程经常会碰到定位不到元素的情况,一般可以从以下几个方面着手解决: 1.Frame/Iframe原因定位不到元素: 这个是最常见的原因,首先要理 ...

  9. 【C语言】printf函数详解

    C语言printf函数详解 一.相关基础知识 请求printf()打印变量的指令取决于变量的类型,例如打印整数用%d符号,打印字符用%c符号,这些符号称为转换说明(conversion specifi ...

  10. uboot移植之环境变量在NandFlash

    一.概述 u-boot环境变量可以设置在Norflash上,也可以在NandFlash上. 倘若环境变量在NorFlash上,再假设S3C2440从NorFlash启动,是能正确从NorFlash上读 ...