#include<stdio.h> #include<string.h> #include<math.h> ]; ]; int main() { int sb; scanf("%d", &sb); int u; ; u <= sb; u++) { int n, i; ; scanf("%d", &n); memset(flag, , sizeof(flag)); ; i <= n; i++) { sca…
Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem Description \ \ \ \    Holion August will eat every thing he has found. \ \ \ \    Now there are many foods,but he does…
King's Game  Accepts: 249  Submissions: 671  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 为了铭记历史,国王准备在阅兵的间隙玩约瑟夫游戏.它召来了 n(1\le n\le 5000)n(1≤n≤5000) 个士兵,逆时针围成一个圈,依次标号 1, 2, 3 ... n1,2,3...n. 第一轮第一个人从 11 开始报数,报…
King's Phone  Accepts: 310  Submissions: 2980  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 阅兵式上,国王见到了很多新奇东西,包括一台安卓手机.他很快对手机的图形解锁产生了兴趣. 解锁界面是一个 3 \times 33×3 的正方形点阵,第一行的三个点标号 1, 2, 31,2,3,第二行的三个点标号 4, 5, 64,5…
1001 Four Inages Strategy 题意:给定空间的四个点,判断这四个点是否能形成正方形 思路:判断空间上4个点是否形成一个正方形方法有很多,这里给出一种方法,在p2,p3,p4中枚举两个点作为p1的邻点, 不妨设为pi,pj,然后判断p1pi与p1pj是否相等.互相垂直,然后由向量法,最后一个点坐标应该为pi+pj−p1,判断是否相等就好了. #include <cstdio> using namespace std; struct node { __int64 x, y,…
zxa and leaf Problem Description zxa have an unrooted tree with n nodes, including (n−1) undirected edges, whose nodes are numbered from 1 to n. The degree of each node is defined as the number of the edges connected to it, and each node whose degree…
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1003 题意 : 给N集合, 每个集合由若干个正整数组成, 要求划分为L个部分, 使得每个部分的所有集合的交集非空 能划分输出YES, 否则NO 思路 : 一共N个集合, 划分的个数为1 - N个, 所以当 L > N 时必然是不行的 考虑如何取到最小的划分个数cnt, 如果 cnt <= L 则可行 方法 : 记录所有…
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1002 思路 : N有若干个质因子, N = a^b * c^d * e^f...... M也有若干个质因子, M = a^(b+k) * c(d+k1) * e^(f+k2)...... N能到达M的条件是它们的质因子必须完全相同 N每次可以乘上它的若干个质因子, 直到这个质因子的幂次等于M这个质因子的幂次 考虑这样一个事实,…
  题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=637&pid=1002 思路 : 考虑这个序列当前的第i个数能有几种组合方法, 前面有2^(i-1)种, 后面有有2^(n-i)种, 本来答案是a[i] * 2^(n-1), 但要求对于某种排列存在相邻且相等的数是不计入答案的 例如 第二组样例 1 2 1 3,   1 1 3中1重复故要减去一个1 可见, 只有前一个数和a[i]相等时, a…
题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=5568 题意 : 给一个长度已知的序列, 给一个值k, 问该序列中有多少种长度为k的上升子序列 思路 : 日常读错题..理解成有多少种值不同且长度为k的上升子序列了, 而原意是只要任意两个子序列的下标不同即可 就按官方题解的解法, dp, 用二维数组dp[i][j]位置i的数作为子序列中第j个数的方案数 故遍历序列, 对一个位置i, 它作为序列中第k大的值, 如果在它之前有b[i] > b[j],…