题目;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. C# Winform添加全局快捷键(老板键)

    using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.W ...

  2. 吴裕雄 25-MySQL 临时表

    MySQL 临时表MySQL 临时表在我们需要保存一些临时数据时是非常有用的.临时表只在当前连接可见,当关闭连接时,Mysql会自动删除表并释放所有空间.临时表在MySQL 3.23版本中添加,如果你 ...

  3. oracle创建数据库步骤

    1.oracle安装成功后, cmd sqlplus,然后system/orcl as sysdba 2.更改scott的密码,scott的默认密码是tiger SQL> alter user ...

  4. git gitlab 使用 提交代码解决冲突

    1.更改完代码后,git push 发生错误 注: 此时,使用 git pull: 更新代码,git 会自动merge不同的更新, a.  如果git 自动merge成功,再进行 git push操作 ...

  5. Vue生命周期,计算属性、方法、侦听器

    vue实例和组件都有生命周期函数,beforeCreate()实例或组件没有被创建的时候执行的钩子函数:created()是实例或组件被创建完成的时候执行的钩子函 数:beforeMount()函数是 ...

  6. 解题(StringTongPei--字符串匹配(动态规划))

    题目描述 问题描述:在计算机中,通配符一种特殊语法,广泛应用于文件搜索.数据库.正则表达式等领域.现要求各位实现字符串通配符的算法.要求:实现如下2个通配符:*:匹配0个或以上的字符(字符由英文字母和 ...

  7. zabbix 自定义监控 排除带报错提示

    UserParameter=lq_data_sqoop,/usr/local/bin/sqoop.sh  2>/dev/null |awk '{print $2}' 注意:2>/dev/n ...

  8. stm32学习基本知识点

    1.AHB系统总线分为APB1(36MHz)和APB2(72MHz),其中2>1,意思是APB2接高速设备 2.Stm32f10x.h相当于reg52.h(里面有基本的位操作定义),另一个为st ...

  9. stm32初做项目心得

    在导师的带领下,基本了解了嵌入式的开发的基本流程: 1.首先从厂家拿到样板之后,首先进行检测,检测什么呢,先检测电源系统,看你的电源系统是否能够正常工作,就是各个管脚是否短路,断路. 2.检测完之后, ...

  10. TableViewCell去除选中效果

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableV ...