CodeForces - 876B H - 差异的可分割性】的更多相关文章

现在有n个整数,在这n个数中找出k个数,保证这k个数中任意两个数差的绝对值可以被m整除. Input第一行输入三个整数n,k,m(2<=k<=n<=100000,1<=m<=100000). 第二行包含n个整数a1,a2,...,  an(0 <= ai <= 10^9 ).Output如果不存在这样的k个数,输出"No":否则输出"Yes"后,在下一行输出这k个数,数与数之间用空格隔开. (存在多种情况,输出任意一种).E…
\(>Codeforces \space 1037\ H. Security<\) 题目大意 : 有一个串 \(S\) ,\(q\) 组询问,每一次给出一个询问串 \(T\) 和一个区间 \([l,r]\) ,要求找出 \(S\) 在 \([l,r]\) 之间的子串中字典序大于 \(T\) 且最小的 \(1 \leq |S|\leq 10^5, 1\leq q \leq 2 \times 10^5\) 解题思路 : 其实这个题一点意思都没有,就是一个 \(sam\) + 线段树合并裸题.. 但…
链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} = \sum_{d|n}f_r(d)\] \(f_r+1\)可以看做\(f_r()\)和\(g(d)\)的狄利克雷卷积因为\(f_0()\)是积性函数,\(g(d)\)也是积性函数,由卷积性质得\(f_{r+1}()\)也是积性函数,那么\(f_r\)同理 对于\(n\)质因数分解得到: \[n=…
题目链接: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…
Problem H. Hell on the MarketsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/H Description Most financial institutions had become insolvent during financial crisis and went bankrupt or…
1. 不加.h的是现在C++中规定的标准,目的在于使C++代码用于移植和混合嵌入时不受扩展名.h的限制, 避免因为.h而造成的额外的处理和修改而加.h的是c语言的用法,但是在c++中也支持这种用法, 主要是为了向下 兼容c 的内容,我们平时尽量不用这种方法 这一点楼上的朋友说的已经很好了 可是#include <iostream> using namespace std;  或者#include <iostream>  void main()  {//...  std::cout(…
H. Eyad and Math   time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Eyad was given a simple math problem, but since he is very bad at math he asked you to help him. Given 4 numbers, a, b, c, and d. Yo…
赛后补题,还是要经常回顾,以前学过的匈牙利都忘记了,“猪队友”又给我讲了一遍... 怎么感觉二分图的匈牙利算法东西好多啊,啊啊啊啊啊啊啊啊啊(吐血...) 先传送一个写的很好的博客,害怕智障找不到了.大神膜%%%    Orz H - Words from cubes Informikas was cleaning his drawers while he found a toy of his childhood. Well, it's not just a toy, it's a bunch…
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…
题意:给定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…