Count a * b Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 211    Accepted Submission(s): 116 Problem Description Marry likes to count the number of ways to choose two non-negative integers a…
Rebuild Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 446    Accepted Submission(s): 113 Problem Description Archaeologists find ruins of Ancient ACM Civilization, and they want to rebuild i…
House Building Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 145    Accepted Submission(s): 123 Problem Description Have you ever played the video game Minecraft? This game has been one of t…
Chip Factory Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 368    Accepted Submission(s): 202 Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips…
Partial Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 228    Accepted Submission(s): 138 Problem Description In mathematics, and more specifically in graph theory, a tree is an undirect…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 186    Accepted Submission(s): 124 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 447    Accepted Submission(s): 201 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort,…
Too Rich Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 245    Accepted Submission(s): 76 Problem Description You are a rich person, and you think your wallet is too heavy and full now. So yo…
Almost Sorted Array Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted arr…
F - Almost Sorted Array Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5532 Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selectio…
题目链接: pid=5527">http://acm.hdu.edu.cn/showproblem.php?pid=5527 题意&题解: 感觉自己真是弱啊,自己想的贪心是错的,根本没想到20,50的特判,╮(╯▽╰)╭ 附我參考的聚聚的题解: http://blog.csdn.net/snowy_smile/article/details/49592521 代码: (差点儿和那位聚聚的一样.ORZ) #include<iostream> #include<alg…
5532 Almost Sorted Array 题目大意:给你一个序列,如果它拿掉其中一个数后,可以是该序列成为非递减或非递增序列,则输出YES. 有两种思路,第一种代码比较简单,是LIS,复杂度nlogn,第二种是On的复杂度. LIS的代码如下. #include <set> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include &l…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5558 Problem Description Alice wants to send a classified message to Bob. She tries to encrypt the message with her original encryption method. The message is a string S, which consists of Nlowercase let…
Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1282    Accepted Submission(s): 902 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3509    Accepted Submission(s): 1122 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.Fo…
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: 我没有读题,只是队友给我解释了题意,然后我根据题意写的题. 大概意思是给n个字符串,从上到下依次标记为1——n,寻找一个标记最大的串,要求这个串满足:标记比它小的串中至少有一个不是它的子串. 输入: 第一行输入一个整型t,表示共有t组数据. 每组数据首行一个整型n,表示有n个串. 接下来n行,每行…
Kingdom of Black and White                                                                                                            Time Limit: 2000/1000 MS (Java/Others)                                                                             …
5573 Binary Tree(构造) 题意:给你一个二叉树,根节点为1,子节点为父节点的2倍和2倍+1,从根节点开始依次向下走k层,问如何走使得将路径上的数进行加减最终结果得到n. 联想到二进制. 思路和这个差不多吧:http://blog.csdn.net/u013068502/article/details/50094561 #include <set> #include <queue> #include <cstdio> #include <vector…
5510 Bazinga 题意:给出n个字符串,求满足条件的最大下标值或层数 条件:该字符串之前存在不是 它的子串 的字符串 求解si是不是sj的子串,可以用kmp算法之类的. strstr是黑科技,比手写的kmp快.if(strstr(s[i], s[j]) == NULL),则Si不是Sj的子串. 还有一个重要的剪枝:对于一个串,如果当前找到的串是它的母串,则下一次这个串不用遍历. #include <set> #include <queue> #include <cst…
A - Pattern String 留坑. B - Bazinga 题意:找一个最大的i,使得前i - 1个字符串中至少不是它的子串 思路:暴力找,如果有一个串已经符合条件,就不用往上更新 #include <bits/stdc++.h> using namespace std; #define N 510 int t, n; int vis[N]; string s[N]; int main() { ios::sync_with_stdio(false); int t; cin >&…
题意: 定义函数\(f(n)\)为\(i \cdot j \not\equiv 0 \; (mod \; n)\)的数对\((i,j)\)的个数\((0 \leq i,j \leq n)\) \(g(n)=\sum_{d|n}f(d)\),求\(g(n) \; mod \; 2^{64}\),其中\(1 \leq n \leq 10^9\) 仰慕叉老师手推公式 分析: 计算\(f(n)\) \(f(n)\)不容易计算,但可以计算它的反面,也就是计算满足\(ij \equiv 0 \; (mod…
链接在这:http://bak.vjudge.net/contest/132442#overview. A题,给出a,b和n,初始的集合中有a和b,每次都可以从集合中选择不同的两个,相加或者相减,得到一个新的数,如果在1~n内的话就放入集合中,并算一次操作,谁先不能操作(所有新数已经存在于集合内的话就不能进行操作)者输.问谁会赢. 可以得到的数字为k*gcd(a,b),那么只要算出在1~n的范围内存在多少个这样的数字,判断一下奇偶性即可. B题,给出n个字符串,问最大的满足条件的字符串的位置,条…
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labelled aand b, where 1≤a≠b≤n) withstood the test of time. Two monks, Yuwgna and Iaka, decide to make…
题意:有\(n\)个点,\(m\)个集合,集合\(E_i\)中的点都与集合中的其它点有一条边权为\(t_i\)的边,现在问第\(1\)个点和第\(n\)个点到某个点的路径最短,输出最短路径和目标点,如果不满足条件则输出\(Evil John\). 题解:题目所给的边数关系太复杂了,我们可以让每个集合中的所有点都与一个虚拟节点连边,而这些点两两却不连,然后再去找\(1\)个和第\(n\)个点的最短路径,不难发现,最终得到的路径为\(dis[i]/2\),所以我们只要用虚拟节点建边然后跑两次dijk…
题意:给你\(n\)个字符串,\(s_1,s_2,...,s_n\),对于\(i(1\le i\le n)\),找到最大的\(i\),并且满足\(s_j(1\le j<i)\)不是\(s_i\)的子串. 题解:直接\(O(n^2)\)然后跑kmp匹配,这里注意要剪枝,不然会T,也就是说对于前\(i-1\)个串,如果它是后面某个串的子串,那么我们就不用对它跑kmp,因为它后面的某个串包含了它. 代码: int t; int n; string s[N]; int ne[N]; bool st[N]…
题意:有\(n\)个数,开始给你两个数\(a\)和\(b\),每次找一个没出现过的数\(i\),要求满足\(i=j+k\)或\(i=j-k\),当某个人没有数可以选的时候判他输,问谁赢. 题解:对于\(a\)和\(b\),我们能有他两得到的最小数一定是\(d=gcd(a,b)\),所以总共能选的数的个数为\(n/d\),判断奇偶即可. 代码: int t; int n,a,b; int main() { ios::sync_with_stdio(false);cin.tie(0);cout.ti…
Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 539    Accepted Submission(s): 204 Problem Description A clique is a complete graph, in which there is an edge between every pair…
Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 249    Accepted Submission(s): 140 Problem Description Farmer John likes to play mathematics games with his N cows. Recently, t…
Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 63    Accepted Submission(s): 60 Problem Description ACM ICPC is launching a thick burger. The thickness (or the height) of a piec…
Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 66    Accepted Submission(s): 59 Problem Description Relative atomic mass is a dimensionless physical quantity, the ratio of…