hdu 5595 GTW likes math(暴力枚举查询)

思路:直接暴力枚举区间[l,r]的整数值,然后max和min就可以了。

AC代码:

 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<math.h>
 7 #include<algorithm>
 8 #include<queue>
 9 #include<set>
10 #include<bitset>
11 #include<map>
12 #include<vector>
13 #include<stdlib.h>
14 using namespace std;
15 #define ll long long
16 #define eps 1e-10
17 #define MOD 1000000007
18 #define N 56
19 #define inf 1e12
20 int main()
21 {
22     int t;
23     scanf("%d",&t);
24     while(t--){
25         int a,b,c,l,r;
26         scanf("%d%d%d%d%d",&a,&b,&c,&l,&r);
27         int Max = -inf;
28         int Min = inf;
29         for(int i=l;i<=r;i++){
30             int cnt = a*i*i + b*i + c;
31             Max = max(Max,cnt);
32             Min = min(Min,cnt);
33         }
34         printf("%d %d\n",Max,Min);
35
36     }
37     return 0;
38 }

时间: 2024-11-05 13:36:22

hdu 5595 GTW likes math(暴力枚举查询)的相关文章

HDU 5596/BestCoder Round #66 (div.2) GTW likes math 签到

GTW likes math Memory Limit: 131072/131072 K (Java/Others) 问题描述 某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学<从自主招生到竞赛>.然而书里的题目太多了,GTW还有很多事情要忙(比如把妹),于是他把那些题目交给了你.每一道题目会给你一个函数f(x)=ax^2+bx+cf(x)=ax?2??+bx+c,求这个函数在整数区间[l,r][l,r]之间的最值. 输入描述 第一行一个整数T,表示数据组数.(T\leq 1000T≤

GTW likes math(简单数学)

GTW likes math Accepts: 472 Submissions: 2140 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Problem Description After attending the class given by Jin Longyu, who is a specially-graded teacher of Mathematics, GTW

GTW likes math(BC 1001)

GTW likes math Accepts: 472 Submissions: 2140 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) 问题描述 某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学<从自主招生到竞赛>.然而书里的题目太多了,GTW还有很多事情要忙(比如把妹),于是他把那些题目交给了你.每一道题目会给你一个函数f(x)=ax2+bx+cf(x)=求这个函

HDU 4930 Fighting the Landlords(暴力枚举+模拟)

HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型,如果先手能一步走完,或者一步让后手无法管上,就赢 思路:先枚举出两个人所有可能的牌型的最大值,然后再去判断即可 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct Player { int rank[15]; } p1, p2; int t, h

hdu 4932 Miaomiao&#39;s Geometry 暴力枚举

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4932 Miaomiao's Geometry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 694    Accepted Submission(s): 180 Problem Description There are N point

HDU 2601 An easy problem(暴力枚举/质因子分解)

An easy problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7963    Accepted Submission(s): 1920 Problem Description When Teddy was a child , he was always thinking about some simple math p

hdu 4445 Crazy Tank (暴力枚举)

Crazy Tank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4562    Accepted Submission(s): 902 Problem Description Crazy Tank was a famous game about ten years ago. Every child liked it. Time f

HDU 4770 Lights Against Dudely 暴力枚举+dfs

又一发吐血ac,,,再次明白了用函数(代码重用)和思路清晰的重要性. 11779687 2014-10-02 20:57:53 Accepted 4770 0MS 496K 2976 B G++ czy Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1360    Accepted Subm

HDU 1431 素数回文-暴力枚举

题目链接:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1431 这道题搞了几天一直Memory Limit Exceeded,始终找不到错误,求指教,不胜感激! 后附有枚举代码! #include <stdio.h> #include <string.h> #include <string> #include <math.h> #include <stdlib.h> #include <i