#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ll;
ll dp[35][35][105];
int n,k; /*
ll dfs(int z,int o,int m) {
if(z<0 || o<0) return 0;
ll &ans=dp[z][o][m];
if(ans>=0) return ans;
ans=0;
ans=dfs(z-1,o,m*inv[2])+dfs(o-1,z,((m+k-1)%k*inv[2])%k);
return ans;
}*/ void solve() {
for(int i=0;i<=33;i++) {
for(int j=0;j<=33;j++) {
for(int m=0;m<k;m++) {
dp[i+1][j][(2*m)%k]+=dp[i][j][m];
dp[i][j+1][(2*m+1)%k]+=dp[i][j][m];
//cout<<dp[n/2][n/2-1][0]<<endl;
}
}
}
}
ll C[65][65];
ll solve2() {
return C[n-1][n/2];
} int id=1;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLIN
int t;
cin>>t; for(int i=0;i<=64;i++)C[i][0]=1;
for(int i=1;i<=64;i++)
for(int j=0;j<=i;j++)
C[i][j]=C[i-1][j]+C[i-1][j-1]; while(t--)
{
memset(dp,0,sizeof(dp));
cin>>n>>k;
if(k==1)dp[0][0][0]=1;
else
dp[0][0][1]=1;
ll ans;
if( (n&1) || k==0) ans=0;
else solve(),ans=dp[n/2][n/2-1][0];
cout<<"Case "<<id++<<": "<<ans<<endl;
}
}

UVA 12063 Zeros and ones 一道需要好好体会的好题的更多相关文章

  1. UVA 12063 Zeros and Ones

    https://vjudge.net/problem/UVA-12063 题意: 统计n为二进制数中,0和1相等且值为m的倍数的数有多少个 dp[i][j][k] 前i位二进制 有j个1 值模m等于k ...

  2. UVA 12063 Zeros and Ones(三维dp)

    题意:给你n.k,问你有多少个n为二进制的数(无前导零)的0与1一样多,且是k的倍数 题解:对于每个k都计算一次dp,dp[i][j][kk][l]表示i位有j个1模k等于kk且第一位为l(0/1) ...

  3. UVa 12063 (DP) Zeros and Ones

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

  4. Uva 12063 Zero and Ones

    给个链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  5. UVA - 10324 Zeros and Ones

    Description Given a string of 0's and 1's up to 1000000 characters long and indices i and j, you are ...

  6. 紫书 习题 10-15 UVa 12063(数位dp)

    大佬真的强!!https://blog.csdn.net/u014800748/article/details/45225881 #include<cstdio> #include< ...

  7. POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题

    题意:给你许多串字符串,从中提取电话号码,输出出现复数次的电话号码及次数. 以下是我艰难的AC历程:(这题估计是我刷的题目题解次数排前的了...) 题目不是很难理解,刚开始想到用map,但stl的ma ...

  8. ZOJ2006 一道很尴尬的string操作题

    ZOJ2006(最小表示法) 题目大意:输出第一个字符串的最小字典序字串的下标! 然后我居然想试一试string的erase的能力,暴力一下,然后20msAC了,尴尬的数据.......... #in ...

  9. 一道颇有难度的JavaScript题

    上次分享了一道题,大家反响不错,很开心自己写的东西有人愿意花时间去看,也给了自己莫大的鼓舞,其实做题虽然不比真正的编程,但是也能够让你发现一些你之前没有注意到的语言层面的问题.所以,这次再分享一道稍微 ...

随机推荐

  1. B.super_log(The Preliminary Contest for ICPC Asia Nanjing 2019)

    同:https://www.cnblogs.com/--HPY-7m/p/11444923.html #define IOS ios_base::sync_with_stdio(0); cin.tie ...

  2. # 组合数学-组合数+lacus定理

    目录 数论-组合数+lacus定理 组合数计算 lacus定理-大组合数取模 数论-组合数+lacus定理 组合数计算 为避免爆long long,\(20!\)就达到了long long 的范围,采 ...

  3. thinkPHP模型before_insert新增前 before_update更新前 before_write写入前 区别

    thinkPHP模型中有个save方法,可用于新增数据和修改数据,这里容易出现混淆. 经过调试: before_write,不管是插入新数据还是修改数据都会执行: before_insert,只有插入 ...

  4. pwd命令和修改PS1环境变量在bash行的显示

    一.pwd:显示当前所在的位置 语法 pwd [选项] ... 描述       打印当前工作目录的完整文件名. -L,--logical              从环境使用PWD,即使它包含符号链 ...

  5. Python-RabbitMQ-RPC(非阻塞版)

    服务器端:rpc_server.py import pika,time connection = pika.BlockingConnection(pika.ConnectionParameters(h ...

  6. Iterator<E>接口

    https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html public interface Iterator<E> ...

  7. linux centos 安装mongoDB

    1.下载mongoDB 例如下载3.2.19 64位版本 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.19.tgz ...

  8. ado.net SqlHelp类

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

  9. dedecms sql 替换 或 删除

    UPDATE dede_archives SET writer='你需要修改的作者' WHERE writer=''; UPDATE dede_archives SET source='你需要修改的来 ...

  10. php连接阿里云mysql

    1.开启Mysql远程访问端口 现在服务器控制台,安全组那边开启3306端口 2.修改Mysql配置文件 vim /etc/mysql/mysql.conf.d/mysqld.cnf,找到bind-a ...