HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/G 题目: Description There is a hill with n holes around. The holes are signed from 0 to n-1.        A rabbit must hide in one of the holes…
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9485    Accepted Submission(s): 4857 Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1.…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9848    Accepted Submission(s): 5011 Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hi…
Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into is the one signed with 0. Then he will…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1273 漫步森林 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3508    Accepted Submission(s): 2339 Problem Description Gardon和小希每天晚上都喜欢到屋外的森林里散步,设森林里有N…
水题,只是想借此记一下gcd函数的模板 #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { int n,m,t; scanf("%d",&t); while(t--){ scanf("%d%d",&m,&n); ) printf("NO\n"); else printf("YES\n"); }…
链接:传送门 题意:狼抓兔子,狼从 0 出发沿逆时针寻找兔子,每走一步的距离为 m ,所有洞窟的编号为 0 - n-1 ,问是否存在一个洞窟使得兔子能够安全躲过无数次狼的搜捕. 思路:简单的拓展欧几里德,设 st 为兔子洞窟编号( 0 <= st < n ),很简单就可以得到一个方程 0 + m * x = n * y + st,化简一下得到 m * x - n * y = st,如果这个方程有解,那么兔子一定能被狼抓到.方程有解的条件是 st % d == 0 ,当 d == 1 时,显然是…
Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 644    Accepted Submission(s): 326 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
E. Mahmoud and Ehab and the xor-MST dp/数学/找规律 题意 给出一个完全图的阶数n(1e18),点由0---n-1编号,边的权则为编号间的异或,问最小生成树是多少 思路 由于一个数k和比他小的数异或,一定可以取到k与所有正整数形成的异或值的最小值.这里简单得形式化证明一下 假设一个数为1000110 那么他的最佳异或和为010(即留下最靠近右边的1其他全部置0) 我们定义\(lsb(x)=x\And(-x)\)由字符形的变量编码我们可以知道,这就可以取得x最…
HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the value of b and only remember the value of a, please tell him the number of different possible results. Input The first line contains a positive integ…
http://acm.hdu.edu.cn/showproblem.php?pid=4388 http://blog.csdn.net/y1196645376/article/details/52143551 好久没有写题了,再这么颓下去就要被彻底踩爆了(已经被彻底踩爆了). 这道题是一道博弈论,从侧面向我们揭示了一个客观规律,取东西的博弈论(不是定理的话)大多数都是从二进制入手(虽然这道题题目很显然是和二进制有关)进行一系列的找规律. 这道题的正解也同样给了我们一种看题的思路,从最基本的条件看…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1723    Accepted Submission(s): 1144 Problem Description Xiao Ming likes coun…
http://acm.hdu.edu.cn/showproblem.php?pid=4731 就做了两道...也就这题还能发博客了...虽然也是水题 先暴力DFS打表找规律...发现4个一组循环节...尾部特殊判断....然后构造一下... #include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <iostream> #include &…
题目 大意: 求二进制的a加到b的进位数. 思路: 列出前几个2进制,找规律模拟. #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include <math.h> #include <stack> #include <vector> using namespace std; int main() { int…
题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围比较大,所以最好通过SG打表的结果找出规律在解. sg(4k+1)=4k+1;sg(4k+2)=4k+2;sg(4k+3)=4k+4; sg(4k)=4k-1; 1 2 4 3 5 6 8 7 Sample Input232 2 323 3 Sample OutputAliceBob SG打表找规律…
题目链接 Problem Description KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered from 1 to n in his closets. Every morning, he puts on a pair of socks which has the smallest number in the closets. Every evening, he puts this pa…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1564 Problem Description New Year is Coming! ailyanlu is very happy today! and he is playing a chessboard game with 8600.The size of the chessboard is n*n. A stone is placed in a corner square. They play…
题目 最近比赛的题目好多签到题都是找规律的考验智商的题目啊,,,我怎么越来越笨了,,,, 通过列举,可以发现规律: 从左往右按位扫这个数: 当数的长度大于1时: 当首位大于3时,答案就是4*4*4*……*4*3(即pow(4,后面的长度-1)*3): 否则,则是 首位的数字*4*4*4*……*4*3: 当数的长度为1时,并且之前的(即其他的)都没有进位,则直接判断一下ans要加多少个: #include<stdio.h> #include<string.h> #include<…
题意:中文的题目 找规律可以发现 sum[1]=a[1]+a[2] sum[2]=a[1]+a[3] sum[n]=a[2]+a[3] 解出a[1],就可以求出其他的了 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include&l…
参考博客:http://www.cnblogs.com/Sunshine-tcf/p/5737627.html. 说实话,官方博客的推导公式看不懂...只能按照别人一样打表找规律了...但是打表以后其实也不是很好看出规律的...而且这个表都写了半天233...(真是太弱了= =)为了打表,我们应当先知道k数列必须是不递减的才能满足值不为0,因此我们可以用递归来写这个表(类似于dfs). AC代码如下: #include <stdio.h> #include <algorithm>…
I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) {    long long res = 0;    for( int i = 1; i <= n; i++ )        res = res + n / i;    return res;} Yes, my error was that I was using the integer…
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, whose lengths are 1,2, 3⋯n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1079 题目大意:给你一个日期(包含年月日),这里我表示成year,month,day,两人轮流操作,每次操作可以将month+1但是,如果下月没有对应的day则只能对day+1(超过该月日数就进入下月一日),或者就day+1.谁最后到达2001.11.4这个日期就是胜者,问先手的人是否能获胜. 解题思路:这个就用上面的P/N分析,一个个月份日期对应的标记上P或N(很快会发现规律只用找每月特定几天),…
A Boring Question 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5793 Description Input The first line of the input contains the only integer T, Then T lines follow,the i-th line contains two integers n,m. Output For each n and m,output the answer i…
题意:给定一个表达式,然后让你求表达式的值. 析:多写几个就会发现规律. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring>…
Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner t…
应该不算太水吧. 17  24   1   8  15   23   5   7  14  16    4   6  13  20  22   10  12  19  21   3   11  18  25   2   9 对于上面的数据,根据题目中的提示,很容易就看到对角线上的数字是11.12.13.14.15.其他的数据,比如说2,从2往右上查就是2.3.4.5.1.描述起来好像很麻烦,但是对着图看一下就可以很容易看明白. 接下来继续观察数据,我们可以看出在第一行实际上是从1开始往右查每个数…
Build a tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 946    Accepted Submission(s): 369 Problem Description HazelFan wants to build a rooted tree. The tree has n nodes labeled 0 to n−1…
题目链接 Problem Description "You shall not pass!" After shouted out that,the Force Staff appered in CaoHaha's hand. As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want. Bu…
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has n positive A1−An and their sum is m. Then for each subset S of A, Yuta ca…