神坑 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. Qt中使用信号和槽的一点心得

    信号(Signal)与槽(Slot)-Qt中的典型机制 这一篇文章中都说得很详细了,这里不再重复,只说一点在实际使用中可能会遇到的问题. 1.一个信号不要同时连接几个槽函数,不然执行的顺序是随机的,最 ...

  2. python模块学习 logging

    1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message') logging.info('This is info messa ...

  3. 能用存储过程的DBHelper类

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. php 删除语句

    if($query&&mysql_affected_rows())echo('数据已被删除');else echo('错误,无法删除'); 通过返回影响的行数 来判断是否已经删除

  5. 工程经济学economics of project summarize

    什么是财务杠杆效应 财务杠杆效应是指由于固定费用的存在而导致的,当某一财务变量以较小幅度变动时.另一相关变量会以较大幅度变动的现象.也就是指在企业运用负债筹资方式(如银行借款.发行债券)时所产生的普通 ...

  6. 多线程-GCD学习笔记

    ********************************* 基本概念 *********************************** 1. Grand Central Dispatch ...

  7. UFLDL教程(四)之Softmax回归

    关于Andrew Ng的machine learning课程中,有一章专门讲解逻辑回归(Logistic回归),具体课程笔记见另一篇文章. 下面,对Logistic回归做一个简单的小结: 给定一个待分 ...

  8. matlab拟合三维椭球

            同学问的,查了下资料. %需要拟合的点的坐标为(0,-174.802,990.048),(0.472,-171.284,995.463),(0.413,-168.639,1003.55 ...

  9. SAP Crystal Dashboard Design 2011 win7 x64 安装

    suggest: unZip the setup package to C:\dashboard\  (make sure that the path cannot contain non-unico ...

  10. codeforces D. Multiplication Table

    http://codeforces.com/contest/448/problem/D 题意:一个n×m的矩阵,a[i][j]=i*j; 然后把a数组排序,找出第k个数. 思路:1-n×m二分枚举,然 ...