题目:http://poj.org/problem?id=2356 N个数,利用鸽巢定理可知应有N+1个前缀和(包括0),因此其%N的余数一定有重复: 同余的两个前缀和之差一定为N的倍数,据此得出答案. 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,a[10005]; long long mo…
链接:传送门 题意:给一个长为 n 的串,问是否有子串的和是 m 的倍数. 思路:典型鸽巢定理的应用,但是这里 n,m 的大小关系是不确定的,如果 n >= m 根据定理可以很简单的判定是一定有解的,当 n < m 的时候就需要去具体寻找一下了,这里构造一个新串 Si = a1 + a2 + a3 + ...... + ai ,如果新串 Si % m = 0 自然就yes了,对于任意一个串 Si % m 的余数范围在 [ 0 , m - 1 ] ,如果出现两个余数相同的新串 S 则就能构成 (…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8776   Accepted: 3791   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
题意: 给定n个数,从中选取m个数,使得\(\sum | n\).本题使用Special Judge. 题解: 既然使用special judge,我们可以直接构造答案. 首先构造在mod N剩余系下的前缀和. \[sum_i = (a_i + sum_{i-1}) mod n\] 剩余系N的完系中显然共有N-1个元素,我们有N个前缀和. 根据鸽巢原理,一定有\(sum_j = sum_i\) 所以这样构造是可行的. TRICK 具体实现的时候用了一个技巧: 从前往后扫描sum数组,记录一个po…
链接:传送门 题意:题意与3370类似 注意:注意输出就ok,输出的是集合的值不是集合下标 /************************************************************************* > File Name: poj2356.cpp > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017年04月30日 星期日 12时24分2…
http://codeforces.com/contest/851/problem/C 题意 - 给出 n 个五维空间的点 - 一个点a为 bad 的定义为 存在两点 b, c, 使的<ab, ac> 为锐角 - 分析 - 在二维平面内, 选取坐标轴原点为a点, 其余点数大于4时, 由鸽巢定理必定有至少两个点位于同一象限, 此时位于统一象限的点与原点夹角为锐角 - 在三维空间内, 选取坐标轴原点为a点, 其余点数大于8时, 同理存在锐角 - 推广, 5维空间内, 除原点外有大于(1<&l…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
Description The input contains N natural (i.e. positive integer) numbers ( N <= ). Each of that numbers . This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your task <= few <= N ) so that the su…
题意:给你N个数,从中取出任意个数的数 使得他们的和 是 N的倍数: 在鸽巢原理的介绍里面,有例题介绍:设a1,a2,a3,……am是正整数的序列,试证明至少存在正数k和l,1<=k<=l<=m,是的和ak+ak+1+……+al是m的倍数,接下来开始证明: 构造一个序列s1=a1,s2=a1+a2,……,sm=a1+a2+……+am,那么会产生两种可能: 1:若有一个sn是m的倍数,那么定理成立: 2:假设上述的序列中没有任何一个元素是m的倍数,令rh ≡ sh mod m;其中h=1,…
[POJ2356]Find a multiple Description -The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them w…