HDU 4627 E(Contest #3)】的更多相关文章

Description There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number. Given an integer n(2 <= n <= 10 9).We should find a pair of positive integer a, b so that a + b = n and [a, b] is…
HDU 4627 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number. Given an integer n(2 <=…
给你一个数 n ( 2 <= n <= 109 ),现在需要你找到一对数a, b (a + b = n),并且使得LCM(a, b)尽可能的大,然后输出最大的 LCM(a, b). (为什么我每次看到题目都想去暴力..Orz    题外话) 这道题先对  n = 2 的情况进行判断,从输出可以知道 n =  2 的时候 ans =  1.接着对 n 进行分情况讨论.当 n = 2k + 1 的时候,ans = k * (k + 1). 当 n = 2k 的时候: 当 k 为偶数的时候 ans…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 243    Accepted Submission(s): 143 Problem Description There are many u…
http://acm.hdu.edu.cn/showproblem.php?pid=4627 分类讨论一下就可以 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<cstring> #include<cmath> #include<set> using namespace std; typedef lo…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b]的最小公倍数最大. 分析:相当简单的的一道题,因为生病好久没做题目,杭电居然是要用__int64,用long long反而错误,为此,WA了无数遍 代码如下: # include<iostream> # include<cstdio> # include<cmath> us…
Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1751    Accepted Submission(s): 374 Problem Description A coding contest will be held in this university, in a huge playground. The…
2013-07-30 20:35 388人阅读 评论(0) 收藏 举报 http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 230    Accepted Submission(s): 136 Prob…
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82974#problem/E 解题思路:数论,从一个数的中间开始往两边找,找到两个互质的数就是,若这个数为奇数,则就是(n/2)*(n-n/2),若这个数是偶数,则还需要判断这个数的一半是否是偶数,若是偶数,则就是(n/2+1)*(n/2-1),若是奇数,则就是(n/2+2)*(n/2-2) 程序代码: #include <iostream> #define l long l…
Problem Description There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number. Given an integer n(2 <= n <= 109).We should find a pair of positive integer a, b so that a + b = n and [a…
Problem DescriptionA coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these blocks. The i-th path goes from the ui-th block to the v…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5988 题目大意: 给定n个点,m条有向边,每个点是一个吃饭的地方,每个人一盒饭.每个点有S个人,有B盒饭.每条边只能被走c次,每条边上都有电线,第一个人通过的时候,不会破坏电线,从第二个人开始,每次都有概率p破坏掉电线.使得每个人都能吃饭,求最小破坏电线的概率. 解题思路: 题目要求我们求最小破坏电线的概率,就是一个最小乘积问题,加上log可以将其转变为加法,那样就可以使用费用刘来解决了. 按以下方…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5988 题意:在acm比赛的时候有多个桌子,桌子与桌子之间都有线路相连,每个桌子上会有一些人和一些食物,现在要吃午饭了,有些人就可能需要到别的桌子去拿食物,但是必须沿着线路走,每根线路第一个人走时没事,接下来的人走时会有一定概率使网络瘫痪,并且每根线路最多可以走c人.现在问使网络瘫痪的最低概率是多少? 思路:建立费用流,由于概率是要相乘,这里可以转换成log后进行计算,最后再转换回来即可. 由于这题…
Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these blocks. The i-th path goes from the u_i-th block to the…
题意: 已知f[1] = f[2] = 1,输入三个数a,b,n,求f[n] = (a*f[n-1]+b*f[n-2])%7的结果 分析: f[n-1]和f[n-2]最多为7种情况(0,1,2,3,4,5,6),则它们的组合最多为49,即周期为49. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <fstream> #include <ctime>…
只是套模板而已(模板其实也不懂). 留着以后好好学的时候再改吧. 题意—— X = a[i] MOD b[i]; 已知a[i],b[i],求在[1, n]中存在多少x满足条件. 输入—— 第一行一个整数t,表示一共t组数据. 第二行两个整数n,m,表示在n以内寻找满足的数,一共m组方程组. 输出—— 一个整数.如果存在满足的x,则输出x的数量.否则输出0. 直接给代码吧—— #include <cstdio> #include <iostream> #include <cma…
最小公倍数最大,也就是尽量让2个数互质,所以把n除以2 从中间向两边找就够了,自己写几组数据就能发现规律. 注意longlong存 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; int main() { int cas; long long s,n; cin>>cas; while(cas--) { ci…
题意描述:给出一个n,要求在所有满足n = a+b的a和b里面求a和b的最小公倍数最大的两个数的最小公倍数. 解题报告:比赛的时候看到这个题的第一反应就是寻找这两个数一定是在a和b比较接近的地方找,这样才能保证a和b的最小公倍数最大,首先,奇数和偶数是一定要分开的讨论的,因为奇数和偶数的一半是不同的,奇数的一半可能就是所要的结果,但是偶数的一半可以确定一定不是所要的结果,因为偶数一半刚好a和b就相等了,最小公倍数就是他们本身了,这是最小的了,然后偶数里面又要分开讨论,一种是这个偶数的一半是奇数,…
Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)Total Submission(s): 37762    Accepted Submission(s): 9221 Problem Description Give you three sequences of numbers A, B, C, then we give you a number…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7677    Accepted Submission(s): 3187 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4912    Accepted Submission(s): 2651 Problem Description ACboy has N courses this term, and he plans to spend at most M days…
HDU 4622 Reincarnation 枚举字符串的起点,构造后缀自动机,每次插入一个字符,就能统计得到当前不同字串的个数,预处理出所有的询问. #include<cstdio> #include<cstring> #define MAXN 2010 #define MAXM 26 int res[MAXN][MAXN]; char str[MAXN]; struct node { node *next[MAXM]; node *pre; int step; int tot;…
Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8984    Accepted Submission(s): 4594 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球…
Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2219    Accepted Submission(s): 1219 Problem Description You are building a house. You’d prefer if all the walls have a precise right…
Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7941    Accepted Submission(s): 4070 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球…
Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11573    Accepted Submission(s): 2823 Problem Description 可 怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验.魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃 公主的肉也能长生不老.年迈…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6072    Accepted Submission(s): 2729 Problem Description Pirates have finished developing the typing software. He called Cathy to tes…
The more, The Better Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6011    Accepted Submission(s): 3555 Problem Description ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物…
X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2980    Accepted Submission(s): 942 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod…
Spring-outing Decision Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 676    Accepted Submission(s): 220 Problem Description Now is spring ! The sunshine is warm , the flowers is coming out . H…