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 −…
开始的时候一看这题感觉很难,觉得肯定有什么很快的办法 不能暴力做(受了上一题10-13的影响) 然后一看那个函数感觉无从下手. 然后看了博客发现,原来这道题就是直接暴力-- 因为n的范围为10的7次方啊 ,不会超时 自己以后要注意数据范围 #include<cstdio> #include<cmath> #include<iostream> #define REP(i, a, b) for(int i = (a); i < (b); i++) using name…
You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is basically a text editor with bells and whistles. You are working on a module that takes a piece of code containing some definitions or other tabular…
把每个电梯口看作一个节点, 然后计算边的权值的时候处理一下, 就ok了. #include<cstdio> #include<vector> #include<queue> #include<cmath> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 112; struct Edge { int v, id; }; st…
水题, Floyd一遍就完了. #include<cstdio> #include<algorithm> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 101; int d[MAXN][MAXN], n; int main() { int u, v, kase = 0; while(~scanf("%d%d", &u…
又是一道非常复杂的构造法-- #include<cstdio> #include<algorithm> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 1123; int L, R, LHs[MAXN], RHs[MAXN], LH, RH, LHi, RHi; int solve() { int lt = 0, rt = 0, t; for(i…