题目;http://acm.hdu.edu.cn/showproblem.php?pid=5461

题意就是在数组中找出a*t[i]*t[i]+b*t[j]的最大值,特别注意的是这里i和i不能相等,想不到的是居然直接暴力排序都能过,而且这题的数据很水,好多有bug的代码都能过

但是我们要对自己要求严一点,尽量吧各种情况考虑到位,如果下面的代码还有不妥,欢迎指正

 #include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll max(ll x,ll y) {
if (x>y) return x;
else return y;
}
ll a[];
int main()
{
ll t,q,i,n,c,w,b,num1,num2;
while (~scanf("%I64d",&t))
{
ll ans=;
while (t--){
scanf("%I64d %I64d %I64d",&n,&c,&b);
q=;
for (i=;i<=n;i++)
scanf("%I64d",&a[i]);
sort(a+,a+n+);
for (i=;i<=n;i++)
if (fabs(a[i])<q) q=fabs(a[i]),w=i;
printf("Case #%I64d: ",ans++);
if (c<&&b<)
{
if (w!=) printf("%I64d\n",c*a[w]*a[w]+b*a[]);
else
{
num1=c*a[]*a[]+b*a[];
num2=c*a[]*a[]+b*a[];
printf("%d\n",max(num1,num2));
}
continue;
}
else if (c>&&b>)
{
printf ("%I64d\n",max(max(c*a[n]*a[n]+b*a[n-], c*a[n-]*a[n-]+b*a[n]), c*a[]*a[]+b*a[n]));
continue;
}
else if (c>=&&b<=)
{
printf ("%I64d\n",max(max(c*a[n]*a[n]+b*a[], c*a[]*a[]+b*a[]), c*a[]*a[]+b*a[]));
continue;
}
else if (c<=&&b>=)
{
if (w!=n) printf("%I64d\n",c*a[w]*a[w]+b*a[n]);
else
{
num1=c*a[n]*a[n]+b*a[n-];
num2=c*a[n-]*a[n-]+b*a[n];
printf("%d\n",max(num1,num2));
}
continue;
}
}
}
return ;
}

hdu 5461(2015沈阳网赛 简单暴力) Largest Point的更多相关文章

  1. hdu 5455 (2015沈阳网赛 简单题) Fang Fang

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5455 题意就是找出所给字符串有多少个满足题目所给条件的子串,重复的也算,坑点是如果有c,f以外的字符也是不 ...

  2. hdu 5459(2015沈阳网赛) Jesus Is Here

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5459 题意 给出一组字符串,每个字符串都是前两个字符串相加而成,求第n个字符串的c的各个坐标的差的和,结果 ...

  3. ACM学习历程—HDU 5459 Jesus Is Here(递推)(2015沈阳网赛1010题)

    Sample Input 9 5 6 7 8 113 1205 199312 199401 201314 Sample Output Case #1: 5 Case #2: 16 Case #3: 8 ...

  4. ACM学习历程—HDU 5451 Best Solver(Fibonacci数列 && 快速幂)(2015沈阳网赛1002题)

    Problem Description The so-called best problem solver can easily solve this problem, with his/her ch ...

  5. hdu 5493 (2015合肥网赛) Queue

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5493 题目大意,t组数据,n个人,n行每行分别是人的身高和这个人的左边或右边比他高的人的个数,输出符合条件 ...

  6. hdu 5491(2015合肥网赛)The Next

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5491 题意就是,T组测试数据.然后L,S1,S2.L的二进制中有x个1,x满足  S1<=x< ...

  7. hdu 5475(2015上海网赛) An easy problem

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5475 题意就是给X赋初值1,然后给Q个操作,每个操作对应一个整数M:如果操作是1则将X乘以对应的M,如果是 ...

  8. hdu 5443 (2015长春网赛G题 求区间最值)

    求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...

  9. HDU 6200 2017沈阳网络赛 树上区间更新,求和

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6200 题意:给个图,有2种操作,一种是加一条无向边,二是查询u,v之间必须有的边的条数,所谓必须有的边 ...

随机推荐

  1. http://sourceforge.net/projects/rtspdirectshow/

    如何做一个解析rtsp协议的h264压缩的实时视频流播放器,带保存功能,目前我有rtsp协议的h264压缩后的实时视频流,目前想开发一个客户端,来播放该实时视频流,同时保存为视频文件,目前似乎有方案是 ...

  2. A Swifr Tour

    Tradition suggests that the first program in a new language should print the words "Hello ,worl ...

  3. 吴裕雄 python深度学习与实践(5)

    import numpy as np data = np.mat([[1,200,105,3,False], [2,165,80,2,False], [3,184.5,120,2,False], [4 ...

  4. CMake Error at cmake/OpenCVUtils.cmake

    CMake Error at cmake/OpenCVUtils.cmake:1047 (message): Failed to download . Status= Call Stack (most ...

  5. hdu3189-Just Do It-(埃氏筛+唯一分解定理)

    Just Do It Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. console.log() 字体颜色

    console.log("%c%s", "color: #fff; background: #20B2AA; font-size: 24px;", " ...

  7. js 生成随机颜色

    var getRandomColor = function(){ return '#'+(Math.random()*0xffffff<<0).toString(16); } <&l ...

  8. Linux下怎么创建和进入带有空格的文件夹

    有时候需要创建带有空格的文件夹,虽然这不是一个好的习惯,但是偶尔会遇到.用的最多的是很多时候需要进入带有空格的文件夹,如"a b"是一个文件夹名. 创建:mkdir "a ...

  9. AssetBundle Manager

    [AssetBundle Manager] AssetBundleManager是一个款Unity公司制作的Unity库. 1.Simulation Mode The main advantage o ...

  10. db2start提示SQL5043,关闭连接终端tty

    db2 V10.3启动的时候提示: 问题1: db2start执行后提示: SQL1072C  The database manager resources are in an inconsisten ...