题目: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…
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…
[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…