Conquer a New Region Time Limit: 5 Seconds      Memory Limit: 32768 KB The wheel of the history rolling forward, our king conquered a new region in a distant continent. There are N towns (numbered from 1 to N) in this region connected by several road…
Sum of divisors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4318    Accepted Submission(s): 1382 Problem Description mmm is learning division, she's so proud of herself that she can figure…
Problem Description In this problem, you are given several strings that contain only digits from '0' to '9', inclusive.An example is shown below.101123The set S of strings is consists of the N strings given in the input file, and all the possible sub…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3662 之前写过这道题,结果被康神吐槽说代码写的挫. 的确,那时候想法太挫了. 题意: 给你三个数n,m,k. 问你存在多少个数列 a1,a2,...,ak,使得他们的和为n,他们的最小公倍数为m. 想法一: 因为 lcm(a1,a2,...,ak)=m,所以a1,a2,a3,...,ak都是m的约数. 因此预处理出来m的约数,记在w[i]里. 设计状态dp[i]…
Browsing History http://acm.hdu.edu.cn/showproblem.php?pid=4464 签到 #include<cstdio> #include<algorithm> using namespace std; ]; int main(){ ; while(~scanf("%d",&n)){ ; while(n--){ scanf("%s",a); ; ;a[i];i++){ sum+=a[i];…
Friend Chains http://acm.hdu.edu.cn/showproblem.php?pid=4460 图的最远两点距离,任意选个点bfs,如果有不能到的点直接-1.然后对于所有距离最远的点都bfs一次.最坏n^2 邻接表 #include<cstdio> #include<cstring> #include<iostream> #include<queue> #include<map> #define mt(a,b) mems…
Draw Something http://acm.hdu.edu.cn/showproblem.php?pid=4450 o(n)统计输入每个数的平方和. #include<cstdio> int main(){ int n,x; while(~scanf("%d",&n),n){ ; while(n--){ scanf("%d",&x); ans+=x*x; } printf("%d\n",ans); } ; }…
意甲冠军:给定的长度可达1000数的顺序,图像password像锁.可以上下滑动,同时会0-9周期. 每个操作.最多三个数字连续操作.现在给出的起始序列和靶序列,获得操作的最小数量,从起始序列与靶序列. 花了一天的时间.我觉得是道非常难的DP.这个阶段非常好划分,对于前面完毕的password锁就不再考虑.问题的关键是这个旋转每次能够的情况非常多. 同一时候也能够发现当I位置上确定移好后,至多影响到后两位.-> dp[i][j][k] 表示当前i位移好后,i+1 为j ,  i+2为k 的次数.…
Description “Be subtle! Be subtle! And use your spies for every kind of business. ”― Sun Tzu“A spy with insufficient ability really sucks”― An anonymous general who lost the warYou, a general, following Sun Tzu’s instruction, make heavy use of spies…
Description P. T. Tigris is a student currently studying graph theory. One day, when he was studying hard, GS appeared around the corner shyly and came up with a problem: Given a graph with n nodes and m undirected weighted edges, every node having o…