hdu 4956(思路题)】的更多相关文章

Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 893    Accepted Submission(s): 407 Problem Description Hanamichi is taking part in a programming contest, and he is assigned to sol…
BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1614    Accepted Submission(s): 566 Problem Description Mr Potato is a coder.Mr Potato is the BestCoder. One night, an amazing…
Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud even if their nation hasn't been so wealthy any more. The merchan…
Building Blocks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2209    Accepted Submission(s): 509 Problem Description After enjoying the movie,LeLe went home alone. LeLe decided to build block…
Select Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1599    Accepted Submission(s): 443 Problem Description One day, Dudu, the most clever boy, heard of ACM/ICPC, which is a very interesting…
Operation the Sequence Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 842    Accepted Submission(s): 288 Problem Description You have an array consisting of n integers: a1=1,a2=2,a3=3,…,an=n. T…
Goffi and Squary Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1171    Accepted Submission(s): 402 Problem Description Recently, Goffi is interested in squary partition of integers.…
Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1445    Accepted Submission(s): 632 Problem Description A sequence b1,b2,⋯,bn are called (d1,d2)-arithmetic sequence if and on…
题目大意 有n个地点(坐标为实数)需要挖矿,让选择一个地点,使得在这个地方建造基地,到n个地点的距离和最短,输出基地的坐标. 题解+代码: 1 /* 2 把这个二维分开看(即把所有点投影到x轴上,再把所有点投影到y轴上),毕竟走的时候只能向上下或者向左右走 3 4 这里以投影到x轴上为例,设这些点是a1...an,且是排过序的(这里以升序为例) 5 当n==2的时候,那么在区间[a1,a2]上的任意一个点都可以满足题意,例如a1=1,a2=2的时候,你取1.5或1.6或1.7...... 6 你…
久しぶり! 发现的一道有意思的题,想了半天都没有找到规律,结果竟然是思路题..(在大佬题解的帮助下) 原题戳>>https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1305<< 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length  …
N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 64256    Accepted Submission(s): 18286 Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in…
思路: 思路题 题目诡异地给了一组可行匹配 肯定有用啊-. 就把那组可行的解 女向男连一条有向边 如果男喜欢女 男向女连一条有向边 跑一边Tarjan就行了 (这个时候 环里的都能选 "增广环"嘛) 嗯 就搞定了 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 4005 int first[N…
传送门 解题思路 比较好想的一道思路题,结果有个地方没开\(long\) \(long\) \(wa\)了三次..其实就是模仿一下树链剖分,重新定义重儿子,一个点的重儿子为所有儿子中到叶节点权值最大的点,然后就和树链剖分一样\(dfs\)一遍,把那些链的顶端的\(sum\)值放到一个数组排个序. 代码 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include&…
传送门 解题思路 比较好想的思路题.首先肯定要把原序列转化一下,大于\(k\)的变成\(1\),小于\(k\)的变成\(-1\),然后求一个前缀和,还要用\(cnt[]\)记录一下前缀和每个数出现了几次,然后统计答案的时候从\(1\)循环到\(k\),每次转化为前缀和相减即可. 代码 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 10…
1.Robberies 连接 :http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱  最脑残的是把总的概率以为是抢N家银行的概率之和- 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋);     正确的方程是:f[j]=max(f[j],f[j-q[i].money]*q…
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统.   Input 输入若干组数据.每组数据包括:导弹总个数(正…
中位数计数 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 909    Accepted Submission(s): 346 Problem Description 中位数定义为所有值从小到大排序后排在正中间的那个数,如果值有偶数个,通常取最中间的两个数值的平均数作为中位数. 现在有n个数,每个数都是独一无二的,求出每个数在多少个包…
Boring count Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 932    Accepted Submission(s): 382 Problem Description You are given a string S consisting of lowercase letters, and your task is cou…
中位数计数 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 999    Accepted Submission(s): 383 Problem Description 中位数定义为所有值从小到大排序后排在正中间的那个数,如果值有偶数个,通常取最中间的两个数值的平均数作为中位数. 现在有n个数,每个数都是独一无二的,求出每个数在多少个包…
题目: Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M. 思路: 刚开始做写了一个尺取法,脑抽的一批.(这几天心情真的是颓的很,连带脑瓜也不好用了,抓紧调整~~~~) 其实可以根据等差数列求和公式求出这个子序列的长度的一个大致的范围为k=sqrt(2*m),然后根据m和k求出首项a1,然后将a1…
摘自题解: 若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. 代码如下: #include <cstdio> #include <cstring> #include <algorithm> #define LL long long #define INF 0x7fffffff #define M 100010 using namespace std; int co…
题意:在[a,b]  [c,d] 之间,和模p等于m的对数 详见代码 #include <stdio.h> #include <algorithm> #include <string.h> #include<cmath> #define LL long long using namespace std; int T; LL a,b,c,d,p,m; LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } LL…
假设删除第k位,把整数A表示成如下形式: A = a * 10^(k+1) + b * 10 ^k + c; 则: B = a * 10^k + c; N = A + B = (11*a+b)*10^k + 2*c; 显然: 11*a+b = N / (10^k) 2*c = N % (10^k) 但是c有可能产生进位,产生的影响为: 11*a+b+1 = N/(10^k)[b+1最多为10,不会影响到11*a的值] 2*c = N % (10^k) + 10^k; 把这两种情况分别考虑一下.…
考虑对立情况,不漂亮的串的形式必然为GGGGR……R……RGGGG 相邻R之间的距离为奇数且相等. #include <cstdio> #include <cstring> #include <cstdlib> #define LL long long int using namespace std; ; ; char str[MAXN]; int main() { int T; scanf( "%d", &T ); while ( T--…
Conturbatio Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 786    Accepted Submission(s): 358 Problem Description There are many rook on a chessboard, a rook can attack the row and column it be…
前言: 在写这篇文章之前,首先感谢给我思路以及帮助过我的学长们 以下4篇博客都是学长原创,其中有很多有用的,值得学习的东西,希望能够帮到大家! 1.手把手教你用C++ 写ACM自动刷题神器(冲入HDU首页) 2.[C#] 逆袭--自制日刷千题的AC自动机攻克HDU OJ 3.C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~ 4.继续Node爬虫 - 百行代码自制自动AC机器人日解千题攻占HDOJ 当初抱着想试试的想法,用过他们的程序,嗯~ o(* ̄▽ ̄*)o. 1.比如那个用C…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956(它放在题库后面的格式有一点点问题啦,所以就把它粘下来,方便读者观看) 题目意思:给出一个范围 [l, r] 你, 问是否能从中找到一个数证明 Hanamichi’s solution 的解法是错的. Hanamichi’s solution 是这样的: 对于某个数 X,从右往左数它的每一位数字(假设第一位是从0开始数).它 偶数位的数字之和 -  奇数位的数字之和  = 3  而且 这个 X…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5534 题意:给你n个点,让你加上n-1条边使他变成一棵树,题目首先给你a[1] a[2].....a[n-1]代表度数为多少时的值,然后问你最大值是多少,n-1条边变成一棵树 思路:这个题首先限制了只能用n^2以下的算法,我们看这个题首先给的东西都是与度数有关,我们建造一棵树度数总和肯定是2*(n-1) 我们其实只要把这个度数当作钱,然后购买相应的商品就可以了,但是你可能买相同的边,有些点你就会没买到造…
E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5391 Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows…
UVa 11572 - Unique Snowflakes 问一个数组中,无重复数字的最长子串长度是多少. 用map维护某数字上次出现的位置.另外用变量last表示上次出现数字重复的位置. 如果出现重复数字,且map[val]>last时,计算当前区间长度,然后last变为map[val]+1. 其他时候增长区间长度即可. 每次遍历一个元素都要更新map[val],用区间长度更新最优解. #include<iostream> #include<vector> #include…