上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: DIV1 250pt题意:给定一个vectorA,若能从里面选出一些数,使得他们按位或的值为x,则称x为吉利数。给定k,问最少要从A里面去掉多少个数,才能使k变为不吉利数。解法:按位考虑。如果A中某元素A[i],将A[i]和k转化成二进制形式,如果某一位A[i]为1而k的为0,则一定不选选取掉A[i],把所有这样的A[i]全部从A中删掉。然后,维护ans,枚举所有k二进制为1的位,计A中有t个元素该位为1,则ans = min(ans, t)。A.size() 12 #include 13 #include 14 #include 15 #include 16 #include 1... 阅读全文
posted @ 2013-12-23 17:12 Plumrain 阅读(207) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:在平面直角坐标系中,只能走到整点,每次有两种移动方法,可以沿平行于坐标轴方向走,也可以沿45度方向走,前者走一步耗时wt,后者走一步耗时st。比如从(x, y)可以走到(x+1, y),(x-1, y),(x, y+1),(x, y-1)四个点,耗时均为wt,也可以走到(x-1, y+1),(x-1, y-1),(x+1, y+1),(x+1, y-1),耗时均为st。给定x, y, wt, st,求从(0, 0)到(x, y)最少耗时多少。解法:水题,见代码。tag: greedy 1 // BEGIN CUT HERE 2 /* 3 4 */ 5 // END . 阅读全文
posted @ 2013-12-23 16:51 Plumrain 阅读(193) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:对于一个字符串s,若对于每一个i = 0 to s.size()-p-1都有s[i] = s[i+p]则称字符串s是p循环的。"CATCATC", "CATCAT", "ACTAC" , "ACT"都是3循环。给定字符串s和一个数字ma,问至少修改多少个s中字符才能使得s变为k循环的,且k 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #i 阅读全文
posted @ 2013-12-21 01:56 Plumrain 阅读(271) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:以linux系统中文件系统的路径表示方法为背景,告诉你某文件的绝对路径和当前位置,求相对路径。具体看样例。解法:模拟题,不多说。每次碰到STL的题自己的代码都会显得很sb...同时速度真的太不够了....tag:模拟题 1 // BEGIN CUT HERE 2 /* 3 * Author: plum rain 4 * score : 5 */ 6 /* 7 8 */ 9 // END CUT HERE 10 #line 11 "RelativePath.cpp" 11 #include 12 #include 13 #include... 阅读全文
posted @ 2013-12-20 12:14 Plumrain 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 题意:对于一个长度n的数列(由1-n组成,n 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #include 21 #include 22 #include 23 #include 24 #include 25 #include 26 #include 27 #include 28 #include 29 #include 30 #include 31 #include 32 #include 33 ... 阅读全文
posted @ 2013-12-20 02:32 Plumrain 阅读(246) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:对于1-9数字三角形如下图,设其为a[i][j],则a[i][j] = (a[i-1][j] + a[i-1][j+1]) % 10。现在对于某个数字三角形, 每行告诉你某一个位置的数字,求整个数字三角形。 n 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #include 21 #include 22 #include 23 #include 24 #include 25 #inclu... 阅读全文
posted @ 2013-12-20 01:52 Plumrain 阅读(147) 评论(0) 推荐(0) 编辑
摘要: C++里面有一些内置函数,实现了一些常用功能。虽然我手写也能写出这些函数,但是在srm或者其他一些需要速度的地方,用内置函数的优势就能体现出来了。1、__gcd(a, b),返回a,b的最大公约数,若a为0返回b,若b为0返回a,若都为0返回0。在头文件中。2、__builtin_popcount(i),返回i的二进制形式中含有1的个数。不知道在什么头文件里。只开或都能使用。3、next_permutation和prev_permutation,两者均是用来求一个序列的排列组合,前者求下一个排列,后者求上一个。比如对string s = "abc",使用next_permu 阅读全文
posted @ 2013-12-19 11:08 Plumrain 阅读(1422) 评论(0) 推荐(0) 编辑
摘要: 题意:有两个变量x和y,三种运算符+,*,-,组成等式"变量 运算符 变量 运算符 变量 运算符 变量",要求每个变量恰好出现两次,且等式的值为val的等式有多少个。注意不计算运算符的优先级,比如2+2*3先计算2+2,最终结果得12。解法:暴力即可。O(2^4 * 3^3)。终于交到200pt了...tag:brute-force 1 // BEGIN CUT HERE 2 /* 3 * Author: plum rain 4 * score : 5 */ 6 /* 7 8 */ 9 // END CUT HERE 10 #line 11 "CountExpre 阅读全文
posted @ 2013-12-19 03:09 Plumrain 阅读(183) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:给出一个size不超过50的数组a和整数n,求x,y,z使得|n - x*y*z|最小,且x,y,z均不再数组a中。若有多组xyz使得|n-x*y*z|最小,输出字典序最小的。a中的元素和n 200000时。 想了一下,也就是说,其实可以不用观察到那个结论,只需要对xyz写3个for语句从1到1010,然后在x*y*z > 200000时break,这道题就能过了....tag:think 1 // BEGIN CUT HERE 2 /* 3 * Author: plum rain 4 * score : 5 */ 6 /* 7 8 ... 阅读全文
posted @ 2013-12-18 21:32 Plumrain 阅读(161) 评论(0) 推荐(0) 编辑
摘要: DIV1 250pt题意:称各个数位只含有4和7的数为lucky number,给定a,b,求[a, b]中的lucky number有多少个。a, b 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #include 21 #include 22 #include 23 #include 24 #include 25 #include 26 #include 27 #include 28 #include 2... 阅读全文
posted @ 2013-12-18 19:15 Plumrain 阅读(117) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页