A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, · · · , an), the next n-tuple in the sequence is formed by taking the absolute differences of neighboring integers: (a1, a2, · · · , an) → (|a1 − a2|, |a2 −…
       Ducci Sequence Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, ... , an), the next n-tuple in the sequence is fo…
Ducci Sequence Description   A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, ... , an), the next n-tuple in the sequence is formed by taking the absolute differences of neighboring integers: ( a1, a2, ...…
水题,算出每次的结果,比较是否全0,循环1000次还不是全0则LOOP AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <sstream> #include <vector> #include <set…
想麻烦了.这题真的那么水啊..直接暴力模拟,1000次(看了网上的200次就能A)后判断是否全为0,否则就是LOOP: #include <iostream> #include <sstream> #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <vector> #include <set> #in…
用到了二分图的一些性质, 最大匹配数=最小点覆盖 貌似在白书上有讲 还不是很懂, 自己看着别人的博客用网络流写了一遍 反正以后学白书应该会系统学二分图的,紫书上没讲深. 目前就这样吧. #include<cstdio> #include<vector> #include<cstring> #include<queue> #include<algorithm> #define REP(i, a, b) for(int i = (a); i <…
很奇怪, 看到网上用的都是匈牙利算法求最大基数匹配 紫书上压根没讲这个算法, 而是用最大流求的. 难道是因为第一个人用匈牙利算法然后其他所有的博客都是看这个博客的吗? 很有可能-- 回归正题. 题目中只差一个数字的时候可以匹配, 然后求最少模板数. 那么肯定匹配的越多就越少, 也就是求最多匹配多少. 这个时候我就想到了二分图最大基数匹配. 那么很容易想到可以匹配的一组之间就连一条弧. 但问题是怎么分成两类??分类的目的是让同一类之间没有弧, 这样才是二分图. 后来发现因为匹配的一组只有一个数字不…
本来以为这道题是考不相交区间, 结果还专门复习了一遍前面写的, 然后发现这道题的区间是不是 固定的, 是在一个范围内"滑动的", 只要右端点不超过截止时间就ok. 然后我就先考虑有包含关系的时候怎么选, 然后发现当两个区间只能放一个的时候时间更短而截 至时间更长的时候,显然更优.然后我就试着每个区间放的时候后后面的比较, 如果两个区间只能放一个, 而且 下个区间更优, 那么当前的就不选.然后排除掉这些区间之后, 能选的就选. 交上去WA.然后我发现中间的区间排除了,但是前面和后面的区间…
这道题的意思紫书上是错误的-- 难怪一开始我非常奇怪为什么第二个样例输出的是2, 按照紫书上的意思应该是22 然后就不管了,先写, 然后就WA了. 然后看了https://blog.csdn.net/wcr1996/article/details/43774331 发现是题意是错误的. 是从1到n的排列变成给的排列, 而不是反过来 其他人的博客都是逆向思维来写, 也就是我原来写误打误撞的那样, 只不过操作反过来, 以及最后 输出是反的.这种方法很值得学习 其实正向也不难, 无非是设置了一种新的优…
思路还是按照紫书,枚举a,得出b, 然后验证. 代码参考了LRJ的. #include <cstdio> #include <iostream> using namespace std; *+; ; int x[maxn], T; void solve() { ; a<M; a++) ; b<M; b++) { bool ok=true; ; i<=*T; i+=) { x[i] = (a*x[i-]+b) %M; <=*T && x[i+]…