UVa12063 Zeros and Ones
神坑 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的更多相关文章
- Trailing Zeros
Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...
- 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 ...
- 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 ...
- lintcode :Trailing Zeros 尾部的零
题目: 尾部的零 设计一个算法,计算出n阶乘中尾部零的个数 样例 11! = 39916800,因此应该返回 2 挑战 O(logN)的时间复杂度 解题: 常用方法: 也许你在编程之美中看到,通过求能 ...
- UVa 12063 (DP) Zeros and Ones
题意: 找出长度为n.0和1个数相等.没有前导0且为k的倍数的二进制数的个数. 分析: 这道题要用动态规划来做. 设dp(zeros, ones, mod)为有zeros个0,ones个1,除以k的余 ...
- Codeforces 556A Case of the Zeros and Ones(消除01)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Andr ...
- 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 ...
- Case of the Zeros and Ones
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Andrew ...
- 10324 - Zeros and Ones
Problem N Zeros and Ones Input: standard input Output: standard output Time Limit: 2 seconds Memory ...
随机推荐
- java是通过值传递,也就是通过拷贝传递——通过方法操作不同类型的变量加深理解(勿删)
head first java里写到“java是通过值传递的,也就是通过拷贝传递”,由此得出结论,方法无法改变调用方传入的参数.该怎么理解呢? 看例子: public class Test1 { pu ...
- C对字符串的部分操作
字符串分割(C++) 经常碰到字符串分割的问题,这里总结下,也方便我以后使用. 一.用strtok函数进行字符串分割 原型: char *strtok(char *str, const char ...
- finalspeed服务器端和客户端安装
https://www.91yun.org/archives/2775 https://www.91yun.org/archives/615 1.首先安装服务器端:一键安装代码 wget -N --n ...
- 【Java】servlet和servlet 容器
servlet不是线程安全的,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,所以你的项目中如果只有一个servlet,那么web容器就只会创建一个实例 ...
- MVC自学系列之一(MVC入门篇)
MVC是如何适用于ASP.NET中的 自从2002年ASP.NET 1.0版本的首次发布,就知道ASP.NET和Web Forms是同样一回事.ASP.NET由抽象两层类所支持: -->Sy ...
- zookeeper kazoo Basic Usage
http://kazoo.readthedocs.org/en/latest/basic_usage.html Basic Usage Connection Handling To begin usi ...
- centos本地源搭建——iso
说明:centos源搭建比另一篇ubuntu源搭建简单些,操作也简单.思路是用iso制作一个本地源,后期需要新软件可以自己添加. 1.进入iso挂载路径,这里是虚拟机,在vm上挂载,在linux下直接 ...
- MSbuild 教程
在.Net framework中,一个不太被大家熟知的工具就是MSBuild.这个命令行工具通过执行XML脚本可以自动生成软件工程文件. 但问题来了,“我为什么想要我的生成过程自动化?”. 其实,大部 ...
- Image Builder, 快速固件生成器
Image Builder, 快速固件生成器, 用此创建固件可以省去重新编译的麻烦,大大缩短编译时间. 利用 Imagebuilder 可以生成自己所需要的固件, 告别和别人伸手乞讨固件的磨练 1. ...
- Constructing Roads(SPFA+邻接表)
题目描述 Long long ago, There was a country named X, the country has N cities which are numbered from 1 ...