Little Zu Chongzhi's Triangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 2195 Accepted Submission(s): 1262 Problem Description Zu Chongzhi (429–500) was a prominent Chinese mathematic…
标题:倍数问题 [题目描述]众所周知,小葱同学擅长计算,尤其擅长计算一个数是否是另外一个数的倍数.但小葱只擅长两个数的情况,当有很多个数之后就会比较苦恼.现在小葱给了你 n 个数,希望你从这 n 个数中找到三个数,使得这三个数的和是 K 的倍数,且这个和最大.数据保证一定有解. [输入格式]从标准输入读入数据. 第一行包括 2 个正整数 n, K.第二行 n 个正整数,代表给定的 n 个数. [输出格式]输出到标准输出.输出一行一个整数代表所求的和. [样例入]4 31 2 3 4 [样例输出]…
C. Ilya And The Tree 题意 给一棵树求每个点到根的路上允许修改一个为0,gcd的最大值. 题解 g是从根到当前点允许修改的最大gcd,gs为不修改的最大gcd.枚举当前点的因子,更新路径上每个因子出现次数,回溯时减去.并用这个因子更新答案.另外当前点修改为0时,还要用父节点的gs更新答案.复杂度\(O(n\sqrt n)\) 代码 const int N=201000; int n; int a[N]; int u,v; VI e[N]; int g[N],gs[N]; in…
题意转载自https://www.cnblogs.com/blumia/p/poj3279.html 题目属性:DFS 相关题目:poj3276 题目原文:[desc]Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an…
http://codeforces.com/gym/100989/problem/L L. Plus or Minus (A) time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output AbdelKader enjoys math. He feels very frustrated whenever he sees an incorrect equation…
Minimal Ratio Tree Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 12 Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description For a tree, which n…