链接

dp[i][j] += dp[i-1][j-g];背包吧

数据太大了 还是JAVA好用

 import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class Big {
public static void main(String[] args)
{
Scanner cin = new Scanner (System.in);
BigInteger[][] dp;
dp = new BigInteger[][];
int i,j,g,s,n;
n = cin.nextInt();
s = cin.nextInt();
for(i = ; i <= n ; i++)
for(j = ;j <= s ; j++)
dp[i][j] = BigInteger.valueOf();
if(s%!=||s/n/>)
{
System.out.println();
}
else
{
s/=;
for(i = ; i <= ; i++)
dp[][i] = BigInteger.valueOf();
for(i = ; i <= n ; i++)
{
for(j = ; j <= s ; j++)
{
for(g = ; g <= ; g++)
{
if(g>j) break;
dp[i][j] = dp[i][j].add(dp[i-][j-g]);
}
}
}
BigInteger ans;
ans = dp[n][s].multiply(dp[n][s]);
System.out.println(ans);
}
} }

URAL1036. Lucky Tickets的更多相关文章

  1. Codeforces Gym 100418J Lucky tickets 数位DP

    Lucky ticketsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view ...

  2. POJ-2346 Lucky tickets(线性DP)

    Lucky tickets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3298 Accepted: 2174 Descrip ...

  3. CF1096. G. Lucky Tickets(快速幂NTT)

    All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k dec ...

  4. DP+高精度 URAL 1036 Lucky Tickets

    题目传送门 /* 题意:转换就是求n位数字,总和为s/2的方案数 DP+高精度:状态转移方程:dp[cur^1][k+j] = dp[cur^1][k+j] + dp[cur][k]; 高精度直接拿J ...

  5. Ural 1036 Lucky Tickets

    Lucky Tickets Time Limit: 2000ms Memory Limit: 16384KB This problem will be judged on Ural. Original ...

  6. POJ 2346:Lucky tickets

    Lucky tickets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3247   Accepted: 2136 Des ...

  7. poj 2346 Lucky tickets(区间dp)

    题目链接:http://poj.org/problem?id=2346 思路分析:使用动态规划解法:设函数 d( n, x )代表长度为n且满足左边n/2位的和减去右边n/2位的和为x的数的数目. 将 ...

  8. codeforces1096G Lucky Tickets

    题目链接:https://codeforces.com/problemset/problem/1096/G 大意:给出\(k\)个数码\(d_1,d_2,\cdots,d_k\),构造一个由这\(k\ ...

  9. Codeforces1096G Lucky Tickets(NTT优化dp)

    设\(f[i][j]\)表示填了\(i\)个数,数位和为\(j\)的方案数 于是方程为: \[f[i][j]=\sum_{k=0}^9 f[i-1][j-k]*[CanUse[k]==1]\] 其中\ ...

随机推荐

  1. UISearchController的使用。(iOS8+)

    这种方法早就发现了,不过一致没用,今天拿过来用,发现了一些问题. 1.这个东西和表视图结合使用很方便,首先,创建新的工程,将表视图控制器作为工程的根视图,并且添加一个导航(当然,你可以不这样做,但是你 ...

  2. 学习之spring注解DI疑惑

    接口定义 package com; public interface IPaly { void say(); } 接口实现类 package com; import org.springframewo ...

  3. 鼠标点击input时,placeholder中的提示信息消失

    html代码: <input type="text" placeholder="多个关键词空格隔开"> 鼠标点击input时,placeholder ...

  4. [PR & ML 4] [Introduction] Model Selection & The Curse of Dimension

    这两部分内容比较少,都是直觉上的例子和非正式的定义,当然这本书中绝大多数定义都是非正式的,但方便理解.后面深入之后会对这两个章节有详细的阐述.

  5. UVA - 572 Oil Deposits(dfs)

    题意:求连通块个数. 分析:dfs. #include<cstdio> #include<cstring> #include<cstdlib> #include&l ...

  6. HDOJ 1042 N! -- 大数运算

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N(0 ≤ N ≤ 1 ...

  7. POJ 1088 滑雪 -- 动态规划

    题目地址:http://poj.org/problem?id=1088 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当 ...

  8. 九度OJ 1442 A sequence of numbers

    题目地址:http://ac.jobdu.com/problem.php?pid=1442 题目描述: Xinlv wrote some sequences on the paper a long t ...

  9. Mac OS X平台上Java环境的配置

    最近换了工作,以前是做c/c++的,但是现在公司的主打产品是使用Java开发,为了以后维护代码,现在开始抽空学习一下Java相关的内容. 在学习之前,首先需要搭建各种平台的开发环境,而我选用的操作系统 ...

  10. phantomjs 自动化测试

    最近网站的质量检查越来越严格,原来开发过程中很多隐蔽的问题,逐渐暴露出来,为提高前端的工作效率,就想到是不是可以在开发过程中能自动的对页面的中一些规范化的东西进行自动监测,这个就可以省去不少麻烦. 整 ...