HDU 5464 Clarke and problem
来源:互联网 发布:中文翻译蒙语软件下载 编辑:程序博客网 时间:2024/05/10 17:11
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 numbera1,a2,...,an and a number p . Count the number of the way to choose some of number(choose none of them is also a solution) from the sequence that sum of the numbers is a multiple of p (0 is also count as a multiple of p ). Since the answer is very large, you only need to output the answer modulo 109+7
Suddenly, a difficult problem appears:
You are given a sequence of number
Input
The first line contains one integer T(1≤T≤10) - the number of test cases.
T test cases follow.
The first line contains two positive integersn,p(1≤n,p≤1000)
The second line containsn integers a1,a2,...an(|ai|≤109 ).
The first line contains two positive integers
The second line contains
Output
For each testcase print a integer, the answer.
Sample Input
12 31 2
Sample Output
2Hint:2 choice: choose none and choose all.简单递推
#include<cstdio>#include<cstring>#include<cmath>#include<iostream>using namespace std;typedef long long LL;const int maxn = 1005;const LL base = 1e9 + 7;int T, n, m, x;LL f[maxn][maxn];int main(){ scanf("%d", &T); while (T--) { scanf("%d%d", &n, &m); memset(f, 0, sizeof(f)); f[0][0] = 1; for (int i = 1; i <= n; i++) { scanf("%d", &x); x = (x%m + m) % m; for (int j = 0; j < m; j++) { f[i][(j + x) % m] = (f[i - 1][j] + f[i - 1][(j + x) % m]) % base; } } printf("%I64d\n", f[n][0]); } return 0;}
0 0
- HDU 5464:Clarke and problem
- HDU 5464 Clarke and problem
- HDU 5464Clarke and problem
- HDU-5464-Clarke and problem
- HDU 5464 Clarke and problem(01背包)
- HDU 5464Clarke and problem(DP)
- hdu 5464 Clarke and problem(DP)
- hdu 5464 Clarke and problem 动态规划
- hdu 5464 Clarke and problem dp
- hdu 5464 Clarke and problem(dp)
- hdu 5464 Clarke and problem (BestCoder Round #56 (div.2))
- HDU 5464 Clarke and problem(DP 01背包)
- HDU 5464 Clarke and problem(类01背包)
- HDU 5469 Clarke and problem (DP)
- hduacm 5464 Clarke and problem 题解
- hdoj 5464 Clarke and problem 【DP】
- hdu5464(Clarke and problem)
- HDU_5464 Clarke and problem
- HDU 5465 Clarke and puzzle
- 关于stm32中GPIO针脚状态问题
- FastJSON使用心得——如何解析带中文或者数字key的数据
- CSS盒模
- 软工视频总结篇
- HDU 5464 Clarke and problem
- 字节流与字符流的区别详解
- 黑盒测试
- 各大it企业编程笔试题,答案自己做的,大家批评指正(更新中)
- Android高效加载大图、多图解决方案,有效避免程序OOM
- GitHub详细教程
- 百度编辑器UEditor 简单使用
- BitMap类型的图形上下文
- Selecting MV Strategy for Temporal ERC