http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3844 第一个,n个数,每次操作最大数和最小数都变成他们的差值,最后n个数相同时输出此时的值,暴力跑. #include<cstdio> int main(){ ]; while(~scanf("%d",&t)){ while(t--){ scanf("%d",&n); ;i<n;i++){ scanf(&qu…
题目传送门 /* 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 思维:对于当前p时间,从现在到未来穿越到过去的是有效的值,排个序,从大到小询问,那么之前添加的穿越点都是有效的, 用multiset保存.比赛时想到了排序,但是无法用线段树实现查询,stl大法好! */ #include <cstdio> #include <algorithm> #include <cstring> #includ…
A是水题,此处略去题解 B - PreSuffix ZOJ - 3995 (fail树+LCA) 给定多个字符串,每次询问查询两个字符串的一个后缀,该后缀必须是所有字符串中某个字符串的前缀,问该后缀最长时,是多少个字符串的前缀. 思路:对所有串构造ac自动机,根据fail指针的性质,a节点的fail指针指向b时,b一定是a的某个后缀.所以每次询问对两个字符串对应的节点在fail树上求一下LCA,插入时经过了LCA节点的字符串的个数便是答案. #include<bits/stdc++.h> us…
Bob wants to pour water Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There is a huge cubiod house with infinite height. And there are some spheres and some cuboids in the house. They do not intersect with others and the house.…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
Market Time Limit: 2 Seconds      Memory Limit: 65536 KB There's a fruit market in Byteland. The salesmen there only sell apples. There are n salesmen in the fruit market and the i-th salesman will sell at most wi apples. Every salesman has an immedi…
Number Game Time Limit: 2 Seconds      Memory Limit: 65536 KB The bored Bob is playing a number game. In the beginning, there are n numbers. For each turn, Bob will take out two numbers from the remaining numbers, and get the product of them. There i…
Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One day, Alice and Bob went to a bakery and bought many cakes. Now we know that they have bought n cakes in the bakery. Both of them like delicious cakes…
Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's…
B http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5552 输入n,表示有n个数1到n.A先拿,B后拿,依次拿,每次可以拿任意一个数,同时会删去这个数的所有因子,最后谁没得拿了谁输. 解法:推了前几个,0,a输,别的a都能赢,证明没想,猜过去的. 网上一个人说的,也不是很清晰:“如果先取的在2-n中取必输,则先取1, 否则则在2-n中取,同时会把1取走,必赢” #include<cstdio> int main(){ in…
A 易知最优的方法是一次只拿一颗,石头数谁多谁赢,一样多后手赢 #include <map> #include <set> #include <ctime> #include <cmath> #include <queue> #include <stack> #include <vector> #include <string> #include <cstdio> #include <cstd…
A - Candy Game 水. #include <bits/stdc++.h> using namespace std; #define N 1010 int t, n; int a[N], b[N]; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); ; i <= n; ++i) scanf("%d", a + i); ; i <…
A: Little Sub and Pascal's Triangle Solved. 题意: 求杨辉三角第n行奇数个数 思路: 薛聚聚说找规律,16说Lucas 答案是 $2^p \;\;p 为 n - 1 中 以2进制表示下1的个数$ 证明 $Ans = \sum\limits_0^n C_n^i \;\%\; 2 = \sum\limits_0^n C_{\frac{n}{2}}^{\frac{i}{2}} \cdot C_{n\;\%\;2}^{i\;\%\;2}$ 我们考虑 $C_{n…
传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5861 Little Sub and his Geometry Problem Time Limit: 4 Seconds      Memory Limit: 65536 KB Little Sub loves math very much, and has just come up with an interesting problem when he is wor…
传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5868 Little Sub and Isomorphism Sequences Time Limit: 3 Seconds      Memory Limit: 65536 KB Little Sub has a sequence . Now he has a problem for you. Two sequences  of length  and  of len…
Twelves Monkeys Time Limit: 5 Seconds      Memory Limit: 32768 KB James Cole is a convicted criminal living beneath a post-apocalyptic Philadelphia. Many years ago, the Earth's surface had been contaminated by a virus so deadly that it forced the sur…
在一次被自己秀死... 飞机 题目: 给出N,K, Q; 给出一个N*N的矩阵  , 与K个特殊点 , 与Q次查询 , 每次查询给出一个C , 问 在这个N*N矩阵中 , 有多少的点是满足这样的一个关系 问题转换就是说 , 当前的坐标X,Y , 满足一个(X+Y)*cnt - sumxy  : 的关系 , cnt 是指在X,Y这个位置 , 有多少个特殊点会被计算到 , sumXY是满足条件的特殊点的横纵坐标的和 ,: 分析: 经过一些分析后 ,你可以得出一个这样的结论 , 在我查询C 的时候 ,…
写这篇博客来证明自己的愚蠢 ...Orz  飞机 题意:给定你个数组,以及一些单点修改,以及询问,每次询问需要求得,最长的字串长度,它在其他位置存在同构 题解:经过一些奇思妙想后 ,你可以发现问题是传化为了查询一个最大的区间这个区间的开头和结尾是相同的 : 所以如果我们知道了某个数的最小位置与最大位置 , 我们是不是就可以很快的知道这个答案了 , 那问题又会来了 , 我怎样得到这个最早和最晚呢 ? 这里相当的疯狂 , 开了20W的set , 没错就是set , 其本身也是排了序的 , 所以我们将…
这个题的话,它每行奇数的个数等于该行行号,如果是0开始的,就该数的二进制中的1的个数,设为k,以它作为次数,2k就是了. #include <stdio.h> int main() { int t; long long k; scanf("%d",&t); getchar(); while (t--) { scanf("%lld",&k); long long ans=1; k=k-1; while (k>0) { if (k&am…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a game, and this time the game is all about the absolute value! Alice has N different positive integers, and each number is not greater than N. Bob has a…
题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种方案,删掉原字符串中的连续$x$个字母, 使得剩下的字符串中任意相邻的两个字母都不同.在这道题中所有的字符串首尾字符看做是相邻的. 对于每个起始位置求出最多往右延伸到的位置,满足该区间代表的字符串是一个满足任意相邻字母不同的字符串. 首先考虑一个连续的满足任意相邻字母不同的字符串.设其长度为$l$…
Latest SQLite binary for January 2015 Well I went through quite a few threads to find an updated, decent sqlite binary. Didn't find any that met that criteria. So I compiled one. Here's SQLite 3.8.7.4 combined into a single source file (the amalgamat…
题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. 所以开$48$棵线段树,和一个永久标记.当对某个区间操作时对这个区间加一层永久标记. 即当前我要查找的第$x$层,实际找的是第$up[i] + x$层. 时间复杂度$O(48nlogn)$ #include <bits/stdc++.h> using namespace std; #define…
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][j]表示长度i,末尾状态为j的最大值,然后每一个位置数字取与不取,不断状态转移就可以 G:就一个模拟题没什么好说的 H:dfs,每次dfs下去,把子树宽度保存下来,然后找最大值,假设有多个.就是最大值+cnt宽度 I:构造,假设r * 2 > R,肯定无法构造.剩下的就二分底边.按等腰三角形去构造就…
ZOJ 3406 Another Very Easy Task #include <cstdio> #include <cstring> const int N = 100005; char s[N]; int main() { bool f = 0; int size = 0; char ch; while(scanf("%c", &ch)!=EOF) { if( !(ch >= 'a' && ch <='z') &…
[题目链接] A. ZOJ 4004 - Easy Number Game 首先肯定是选择值最小的 $2*m$ 进行操作,这些数在操作的时候每次取一个最大的和最小的相乘是最优的. #include <bits/stdc++.h> using namespace std; const int maxn = 100010; int T, n, m; long long a[maxn]; int main() { scanf("%d", &T); while(T--) {…
D - Beauty of Array Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3872 Description Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integ…
A - Easy Number Game 水. #include <bits/stdc++.h> using namespace std; #define ll long long #define N 100010 ll arr[N]; int n, m; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); ; i <= n; +…
A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 10000 + 100; int SG[maxn]; vector<int> g[maxn]; int mex(int u) { //minimal exc…