题目链接: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
题目链接:uva 1521 - GCD Guessing Game
题目大意:给定一个数N,现在又一个数x,在1~N之间,现在每次可以猜一个数a,返回gcd(x,a),问说最少猜几次可以确定x。
解题思路:其实就将1~N里面的素数都要考虑一遍,因为有一个N的限制,所以每次选出来的素数的积不大于N即可。
#include
#include
#include
using name...
分类:
其他好文 时间:
2014-08-02 23:27:44
阅读次数:
302
题目链接:点击打开链接
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
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
Codeforces Round #259 (Div. 1)
A题:最大值为i的期望为(in?(i?1)n)?i/mn,那么总期望为∑m1(in?(i?1)n)?i/mn,然后化简一下公式,答案为m?∑m?11i/mn
B题:状压DP,只需要用到小于59的素数,一共有16个,dp[n][s]表示当前放到第n个数字,素数使用的集合为s的最小值,S[k]表示k数字对应会用掉哪几个素数,然后...
分类:
其他好文 时间:
2014-08-02 12:49:43
阅读次数:
284
这题的大意就是 给出一个数n, 找到它所有的因子, 然后把这些(因子的因子数)的立方和求出来。
题目的时限虽然很宽,但是数据很BT。首先,公式必须找出来。
证明如下:
先将n质因数分解成形如n = a ^m * b ^ p * c ^q *........;
那么要求的结果为函数g(x)的值;
我们以n有2个质因数为例子;
g(n) = g(a ^m * b...
分类:
其他好文 时间:
2014-08-01 16:19:11
阅读次数:
228
1 #include 2 #include 3 #include 4 #include //使用 assert.h 中的 assert 宏来限制非法函数的调用; 5 using namespace std; 6 7 // 判断是否为素数 8 int is_prime(int x) ...
分类:
其他好文 时间:
2014-08-01 12:53:11
阅读次数:
245