
贪心
Egqawkq
北航CS研一在读
展开
-
Codeforces Round #436 (Div. 2)D. Make a Permutation! codeforces-864D. Make a Permutation!
D. Make a Permutation!time limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputIvan has an array consisting of原创 2017-09-26 20:40:51 · 299 阅读 · 0 评论 -
codeforces 865 C. Buy Low Sell High
D. Buy Low Sell Hightime limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputYou can perfectly predict the pric原创 2017-10-02 11:55:37 · 532 阅读 · 0 评论 -
codeforces 884C. Bertown Subway
C. Bertown Subwaytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe construction of subway in Bertown is a原创 2017-10-28 13:10:24 · 655 阅读 · 0 评论 -
Codeforces1157E. Minimum Array
题目:http://codeforces.com/contest/1157/problem/E题意:给定整数型n,a与b数组长度均为n,其中的a与b中的每个元素大小为0<= a[i] (或者b[i]) <n,现在可以改变b数组的元素顺序,用现在的b数组与a数组做如下操作: c[i] = ( a[i] + b[i] ) % n 最后操作完之...原创 2019-04-28 21:09:06 · 369 阅读 · 0 评论 -
Codeforces 1154 G. Minimum Possible LCM (贪心+简单数论)
题目:给定数组A,找到下标I和J使得A[i]和A[j]的最小公倍数最小,数据范围是2<=n<=1e6,A[i]<=1e7思路:如果是按照正常做法求解GCD和LCM,那么是O(n^2)复杂度,题目要求是NlgN内求解,所以转换思路每次枚举GCD按照当前的GCD去选出满足条件的答案。需要注意的是对于同一个GCD:d而言,两个数均为d的倍数,那么这两个数最小即可,没有必要继续枚举下...原创 2019-04-24 23:12:44 · 340 阅读 · 0 评论