B. Divisiblity of Differences time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output You are given a multiset of n integers. You should select exactly k of them in a such way that the difference b…
B. Divisiblity of Differences You are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible. Numbers can be repeated in the origi…
B. Divisiblity of Differences time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output You are given a multiset of n integers. You should select exactly k of them in a such way that the difference b…
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C家的距离是c  (A- >Rabbit   B- >Owl    C ->Eeyore),他不能连续两顿饭都在同一位朋友家里蹭 他现在位于A的家里, 请问他一天最少要跑多少路. 当然是要找一条最短的路折返跑了啊,是不是很简单. #include<bits/stdc++.h> us…
B. Divisiblity of Differencestime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a multiset of n integers. You should select exactly k of them in a such way that the difference between an…
http://codeforces.com/contest/876/problem/B 题意: 给出n个数,要求从里面选出k个数使得这k个数中任意两个的差能够被m整除,若不能则输出no. 思路: 差能够被m整除,其实就是对m取余的余数相同.那么就统计n个数的余数丢到一个map里面,最后判断是否有某个数的数量大于等于k. 代码: #include <stdio.h> #include <map> #include <vector> using namespace std;…
题目链接:http://codeforces.com/contest/876/problem/B 题意: 给你n个数a[i],让你找出一个大小为k的集合,使得集合中的数两两之差为m的倍数. 若有多解,输出任意一个集合即可. 题解: 若一个集合中的数,两两之差为m的倍数,则他们 mod m 的值均相等. 所以O(N)扫一遍,对于每个数a:vector v[a%m].push_back(a) 一旦有一个集合大小为k,则输出. AC Code: #include <iostream> #includ…
题意:给定n个数,从中选取k个数,使得任意两个数之差能被m整除,若能选出k个数,则输出,否则输出“No”. 分析: 1.若k个数之差都能被m整除,那么他们两两之间相差的是m的倍数,即他们对m取余的余数是相同的. 2.记录n个数对m取余的余数,计算出数量最多的余数ma. 3.ma>=k,才能选出,并输出即可. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #in…
D. Palindrome Degree 题目连接: http://www.codeforces.com/contest/7/problem/D Description String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (ev…
[题目链接]:http://codeforces.com/contest/514/problem/C [题意] 给你n个字符串; 然后给你m个询问;->m个字符串 对于每一个询问字符串 你需要在n个字符串里面找到和它的长度相同,且只有一个位置的字符不同的字符串; 或者告知这是不存在的; [题解] 字符串hash 因为只有3个字符 所以权值就为3^x; 找个大质数取模就好: 不够大就再大一点.. 然后对于每一位,尝试换成其他两个字母,看看存不存在; [Number Of WA] 3 [完整代码]…