CF577B Modulo Sum 好题】的更多相关文章

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that…
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subse…
B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence…
B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/B Description You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such…
 Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence a…
B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence…
                                                         B. Modulo Sum                                                                                                  time limit per test 2 seconds                                                    …
http://codeforces.com/problemset/problem/577/B 题意:有n个数,求有无一个子序列满足和是m的倍数 思路:用模下的背包做,发现n是十的六次方级别,但是有个神奇的性质,就是抽屉原理,当n大于等于m的时候,总会有sum[i]和sum[j]满足sum[i]%m=sum[j]%m,于是当n>=m的时候就可以特判掉,DP的复杂度就是O(n^2)的 总结:一定要记住,在模m下的前缀和这样的东西,一定要记得有抽屉原理! 然后这题的XX细节真是坑死我了 #includ…
题 题意 给你n(1 ≤ n ≤ 106)个数a1..an(0 ≤ ai ≤ 109),再给你m( 2 ≤ m ≤ 103)如果n个数的子集的和可以被m整除,则输出YES,否则NO. 分析 分两种情况: 当n>m时,s[i]表示a[i]前缀和,s[i]%m的取值为0到m-1,由抽屉原理可知,s[i]一定有重复的,假如重复的是s[l]和s[r],那么s[r]-s[l]也就是l+1到r这些钱加起来就是m 的倍数.故答案为YES. 当n≤m时,我们用dp[i][j]==1表示前i个数可以得到对m取余为…
#include <iostream> #include <stdio.h> #include <algorithm> #define lson rt<<1,L,mid #define rson rt<<1|1,mid+1,R /* AC 水题 题意:给出n个数,两种操作 U i x 将第i个数改成x Q x y 查询[x,y]中两个数的和的最大值,这两个数不能为同一个 即只要求该区间第一大和第二大的数,他们的和即为答案 */ using nam…