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…
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…
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…
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 index…
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…
这道题我改啊,改啊,交啊,就对了. #include <stdio.h> #include <stdlib.h> #include <math.h> #include<cstring> #include<algorithm> using namespace std; ; ; int a[N]; int p[M]; ],cover[M*]; void Prime() { a[] = ; ; i<sqrt(N); i++) { if(a[i])…
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.…
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…
题目传送门 /* 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 思维:对于当前p时间,从现在到未来穿越到过去的是有效的值,排个序,从大到小询问,那么之前添加的穿越点都是有效的, 用multiset保存.比赛时想到了排序,但是无法用线段树实现查询,stl大法好! */ #include <cstdio> #include <algorithm> #include <cstring> #includ…
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') &…
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…
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…
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…
 Prime Ring Problem Time Limit: 10 Seconds      Memory Limit: 32768 KB A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime…
Modulo Query Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Peter came across a function which looks like: F(1, X) = X mod A1. F(i, X) = F(i - 1, X) mod Ai, 2 ≤ i ≤ N. Where A is an integer array of length N, X is a non-negative integer n…
题意:有N个数字,M个操作,然后回答每个Q开头的询问 操作形式: A val pos:在pos位置上+val Q l r:询问l~r之间有多少个质数 R val l r:把l~r之间的数字替换成val 分析:建成两棵树,一棵更新 原数列,一棵更新 质数序列(只有0,1) #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std;…
Prime Distance Time Limit: 2 Seconds      Memory Limit: 65536 KB The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the ques…
// 数论题,增强的筛法,回想素数筛法 // 只要筛到最大数的开方,剩下的就是素数 // 于是这里,开一个 sqrt(2^31) 大约 65536 的素数表,然后 // 对于每个 L~U 的区间,筛掉 sqrt(U) 之内的素数的倍数即可 #include <iostream> #include <math.h> #include <map> #include <stack> #include <queue> #include <vecto…
0--M对某个数字取模,相当于把0--M区间进行切割,每次暴力切割一下.结果的算的时候二分一下即可... 看了官方题解才会... #include<cstdio> #include<cstring> #include<queue> using namespace std; +; ; int T,m,sz; struct X { int x; long long y; bool operator<(const X&a)const { return x <…
题目链接  2016 ZJCPC Problem E 考虑一个开区间$[0, x)$对$a_{i}$取模的过程. $[0, x)$中小于$a_{i}$的部分不变,大于等于$a_{i}$的部分被切下来变成了$[0, x$ $mod$ $a_{i})$. 现在考虑开区间$[0, m+1)$,依次对$a_{1}, a_{2}, ..., a_{n}$取模. 考虑到一个数对$10^{5}$个数逐次取模,有效的取模至多$logm$次,那么同理, 这个区间最多分裂出$nlogm$个区间,这个过程用map实现…
Help Bob Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a game very popular in ZJU at present, Bob didn't meant to participate in it. But he decided to join it after discovering a lot of pretty girls playing it. There are n stones on the…
2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1951 ZOJ:2679先来~ 水题大意:(题目大意:我什么时候改名了哇T T) 给你一个5位数的中间三个字母,还有一个数N让你求能被N整除的最大的五位数. 思路: 直接暴力枚举.... #include<cstdio> int…
ZOJ Monthly, October 2015 K题 二分答案+验证 #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> using namespace std; const double pi=3.1415926535898; +; struct cuboids { double z; double widt…
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…
赛后总结: TJ:今天我先到实验室,开始看题,一眼就看了一道防AK的题目,还居然觉得自己能做wwww.然后金姐和彭彭来了以后,我和他们讲了点题目.然后金姐开始搞dfs,我和彭彭看榜研究F题.想了很久脑子都炸了,做不下去了.然后在等金姐做完以后,彭彭说了D题题意,然后金姐开始写另外一道搜索题.做完两道搜索以后,金姐让我写那道线段树的题目.我搞了很久...然后超时了,因为要用素数筛,然后加了素数筛也做不出呜呜.金姐和彭彭把Ant的题目公式给搞出来了.开始敲.后来是因为取模的问题,就一直没搞成功.比赛…
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…
主题链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=4535 How Many Sets I Time Limit: 2 Seconds      Memory Limit: 65536 KB Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is…