题目链接:Codeforces 453B Little Pony and Harmony Chest
题目大意:给定一个序列a, 求一序列b,要求∑|ai?bi|最小。并且b中任意两数的最大公约束为1.
解题思路:因为b中不可能含有相同的因子,所以每个素数只能使用1次。又因为说ai最大为30,所以素数只需要考虑到57即可。因为即使对于30而言,59和1的代价是一样的。
所以有dp[i...
分类:
其他好文 时间:
2014-08-02 23:28:44
阅读次数:
312
题目链接:Codeforces 453 Little Pony and Summer Sun Celebration
题目大意:n个节点,m条边,然后m行给定边,最后一行表示每个节点需要进过的次数为奇数次还是偶数次。
解题思路:构造,任意从一个奇数点开始(统一森林的处理),然后每次向下遍历没有经过的节点,并且回溯,每次回溯都要判断一下刚才走过的点满不满足条件,不满足的话就再走一次。最后...
分类:
其他好文 时间:
2014-08-02 23:28:14
阅读次数:
218
题目链接:点击打开链接
题意:
给定一个无向图
任选一个起点,使得访问每个点的次数奇偶与最后一行的输入一致
思路:
选一个奇数点作为起点
dfs树一下,若子节点不满足则先走到子节点再回来
如此就能保证所有子节点合法
这样dfs结束后最多只有根节点不满足,随便找一个与根相连的点调整一下。
#include
#include
#include
#include
#includ...
分类:
其他好文 时间:
2014-08-02 21:02:49
阅读次数:
433
题目范围给的很小,所以有状压的方向。我们是构造出一个数列,且数列中每两个数的最大公约数为1;给的A[I]#include#include#include#define inf 0x3f3f3f3fusing namespace std;int cnt=0;int c[123],a[123];int ...
分类:
其他好文 时间:
2014-08-02 20:53:04
阅读次数:
206
题目链接:点击打开链接
b的数字最多只能达到59,因为选>=60 不如选1
所以状压一下前面出现过的素数即可,在59内的素数很少
然后暴力转移。。
#include
#include
#include
#include
#include
const int Inf = (int)(1e9);
const int S = 1 << 17;
const int N = 100 + 2...
分类:
其他好文 时间:
2014-08-02 18:20:53
阅读次数:
225
题目链接:点击打开链接
#include
#include
#include
using namespace std;
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
typedef long long ll;
int main()
{
int i, j;
double m,n;
while...
分类:
其他好文 时间:
2014-08-02 18:20:43
阅读次数:
233
A. Little Pony and Crystal Mine水题,每行D的个数为1,3.......n-2,n,n-2,.....3,1,然后打印即可#include #include #include #include using namespace std;int main(){ int...
分类:
其他好文 时间:
2014-08-02 18:01:13
阅读次数:
251
题目链接:Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
求给出的序列最少移动多少次成为非下降序列。移动方式:只能将最后一个元素移到第一个位置 即:a1,?a2,?...,?an?→?an,?a1,?a2,?...,?an?-?1.
从后前开始搜非下降的子序列,然后前面的子序列接在其后面,最后判断变化后的...
分类:
其他好文 时间:
2014-08-02 15:40:43
阅读次数:
273
Description
N children are sitting in a circle to play a game.
The children are numbered from 1 to N in clockwise order. Each of them has a card with a non-zero integer on it in his/her hand. Th...
分类:
其他好文 时间:
2014-08-02 15:37:33
阅读次数:
259
A TabControl contains tab pages, which are represented by TabPage objects that you add through the TabPages property. The order of tab pages in this c...
分类:
其他好文 时间:
2014-08-02 15:19:03
阅读次数:
201