Osu! Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5078 Mean: 略. analyse: 签到题,直接扫一遍就得答案,但是现场赛的时候也是卡了好久,估计队友也是被爆int坑了吧. Time complexity: O(n) Source code:  // Memory Time // 1347K 0MS // by : Snarl_jsb // 2014-11-15-10.58 #include<algori…
Galaxy Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5073 Mean: 在一条数轴上,有n颗卫星,现在你可以改变k颗卫星的位置,使得剩下的n-k颗卫星到某个点(不固定)的距离的平方和最小. 抽象成数学语言后等价于:数轴上有n个点,现在去掉k个点,使得剩下的n-k个点的方差最小,求方差*n的值. analyse: 一道让人很容易想偏的数学题.首先说一下我的思路: 1)我们最终的目的是让这n-k个点尽量的集中,所以去…
Hatsune Miku Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5074 Mean: 有m种音符(note),现在要从这m种音符中选出n个来组成一首歌,相邻两个音符之间会有一个评分的方式,即score(i,j),而score(i,j)题目已经给出,现在要你按照题目的规定来选出n个音符来使得最终的分数最高. analyse: 鞍山赛区第二大水题,很简单的dp. 具体思路:dp[i][j]表示第i个音符选择的是第j种.…
推公式 #include <cstdio> #include <cmath> #include <iomanip> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int N = 50000+3; ll a[N], b[N]; int main() { int T, n, m, len; ll x, sum, ans…
简单dp #include <stdio.h> #include <cstring> #include <iostream> #include <map> using namespace std; typedef unsigned long long ull; const int N = 105; int n, m, a[N]; int s[N][N], dp[2][N]; void pt(int x ){ for(int i = 1; i <= m;…
模拟题: add的时候出现过的则不再添加 close的时候会影响到top rotate(Prior.Choose)的时候会影响到top /*=============================================================== * Copyright (C) 2014 All rights reserved. * * File Name: hdu5071.cpp * Author:sunshine * Created Time: 2014-11-11 *…
最后一次参加亚洲区…… 题意:给出n(3 ≤ n ≤ 105)个数字,每个数ai满足1 ≤ ai ≤ 105,求有多少对(a,b,c)满足[(a, b) = (b, c) = (a, c) = 1] or [(a, b) ≠ 1 and (a, c) ≠ 1 and (b, c) ≠ 1],都互素或都不互素. 思路:如果是两个数,互素比较好求,边遍历边分解质因子,利用容斥原理即可知道前面与自己互素的有多少.left_prime[i]表示左边与自己互素的,left_no_prime[i]表示左边与…
题目I - Osu! - HDU 5078 题目分析:最水的一道题吧,求两点间的距离和时间差值的最大比值 #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; ; ; struct Point { double x, y, time; }; double Dist(Point a, Point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5150 题目大意:给一幅N个点M条边的无向图,有一些边,其中一部分只能涂红色,一部分只能涂黑色,一部分两种颜色都可以涂.现要求红色的边不超过K条的生成树个数模1e9+7的值. 思路:感谢昂神滋磁,贴链接:http://sd-invol…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5155 There are N guests checking in at the front desk of the hotel. 2K (0 ≤ 2K ≤ N) of them are twins.There are M room…