HDU 5464 ( Clarke and problem ) (dp)】的更多相关文章

dp[i][j] := 前i个数和为j的情况(mod p) dp[i][j] 分两种情况 1.不选取第i个数 -> dp[i][j] = dp[i-1][j] 2.   选取第i个数 -> dp[i][j] = dp[i-1][t] ((t+a[i])%p==j) (为什么很简单的题,思路也有了,比赛的时候就是写不对呢?) #include <iostream> #include <cstdio> #include <cstring> using names…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5464 Clarke and problem  Accepts: 130  Submissions: 781  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个学生,在做题. 突然一道难题难到了克拉克,这道题是这样的: 给你…
Clarke and problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5464 Description 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个学生,在做题. 突然一道难题难到了克拉克,这道题是这样的: 给你nn个数,要求选一些数(可以不选),把它们加起来,使得和恰好是pp的倍数(00也是pp的倍数),求方案数. 对于nn很小的时候,克拉克是能轻…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1864 题目: 最大报销额 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25248    Accepted Submission(s): 7771 Problem Description 现有一笔经费可以报销一定额度的发票.允许报销的发票类…
题目链接 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't matter,I will give you a link: Here is the l…
守护雅典娜 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 324    Accepted Submission(s): 91 Problem Description 许多塔防游戏都是以经典的“守护雅典娜”为原型的.玩家需要建立各种防御工具来阻止怪物接近我们的女神——雅典娜. 这里,我们可以建造的防御工具只有标准圆形状的防御墙,建立在雅典…
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18313    Accepted Submission(s): 8197 Problem Description A ring is compose of n circles as shown in diagram. Put natural numbe…
题目链接 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他. Input 第一行整数T,表示测试组数.后面T行,每行一个整数 n (1<=|n|<=10^5). Output 输出1/n. (是循环小数的,只输出第一个循环节). Sample Input 4 2 3 7 168 Sample Output 0.5 0.3 0.142857 0.005952380 分析:…
有n(2e4)个宝石两个人轮流从左侧取宝石,Alice先手,首轮取1个或2个宝石,如果上一轮取了k个宝石,则这一轮只能取k或k+1个宝石.一旦不能再取宝石就结束.双方都希望自己拿到的宝石数比对方尽可能多.问你,先手比后手多拿的最大宝石数. dp[s][k] 表示从已经拿了s个,这一次可以拿k个,也可以拿k+1个. 那么dp[s][k] 表示 已经拿了s个,这一次可以拿k个或k+1个的最大差值. #include <cstdio> #include <cstdlib> #includ…
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned into a student and read a book. Suddenly, a difficult problem appears:  You are given a sequence of number a1,a2,...,an and a number p. Count the numbe…