麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

最小函數(shù)值 洛谷2085 堆

2019-11-10 19:37:48
字體:
供稿:網(wǎng)友

題目描述


有n個函數(shù),分別為F1,F2,…,Fn。定義Fi(x)=Ai*x^2+Bi*x+Ci (x∈N*)。給定這些Ai、Bi和Ci,請求出所有函數(shù)的所有函數(shù)值中最小的m個(如有重復(fù)的要輸出多個)。

輸入格式:


輸入數(shù)據(jù):第一行輸入兩個正整數(shù)n和m。以下n行每行三個正整數(shù),其中第i行的三個數(shù)分別位Ai、Bi和Ci。Ai<=10,Bi<=100,Ci<=10 000。

輸出格式:


輸出數(shù)據(jù):輸出將這n個函數(shù)所有可以生成的函數(shù)值排序后的前m個元素。這m個數(shù)應(yīng)該輸出到一行,用空格隔開。

說明


數(shù)據(jù)規(guī)模:n,m<=10000

Analysis


題意直接粗暴,不知道要怎么說了 開一個優(yōu)先隊列記錄函數(shù)類型、當(dāng)前x的值 一開始把所有函數(shù)的最小值壓進去,然后此時的堆頂一定是最小的 那么我們把堆頂?shù)膞+1再壓回去,如此做m次

重裝系統(tǒng)之后什么都沒了,氣死

Code


#include <cstdio>#include <cstdlib>#include <cstring>#include <ctime>#include <iostream>#include <algorithm>#include <string>#include <vector>#include <deque>#include <list>#include <set>#include <map>#include <stack>#include <queue>#include <numeric>#include <iomanip>#include <bitset>#include <sstream>#include <fstream>#define debug puts("-----")#define rep(i, st, ed) for (int i = st; i <= ed; i += 1)#define drp(i, st, ed) for (int i = st; i >= ed; i -= 1)#define fill(x, t) memset(x, t, sizeof(x))#define f(x, a, b, c) x * x * a + x * b + c#define pb push_back#define PI (acos(-1.0))#define EPS (1e-8)#define INF (1<<30)#define ll long long#define db double#define ld long double#define N 20001#define E N * 8 + 1#define MOD 100000007#define L 255using namespace std;vector<int> a, b, c;struct pos{ int x, type; bool Operator >(const pos &r) const{ pos l = *this; return f(l.x, a[l.type], b[l.type], c[l.type]) <= f(r.x, a[r.type], b[r.type], c[r.type]); } bool operator <(const pos &r) const{ pos l = *this; return f(l.x, a[l.type], b[l.type], c[l.type]) > f(r.x, a[r.type], b[r.type], c[r.type]); }};inline int read(){ int x = 0, v = 1; char ch = getchar(); while (ch < '0' || ch > '9'){ if (ch == '-'){ v = -1; } ch = getchar(); } while (ch <= '9' && ch >= '0'){ x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * v;}int main(void){ int n = read(), m = read(); rep(i, 1, n){ a.pb(read()); b.pb(read()); c.pb(read()); } PRiority_queue<pos> heap; rep(i, 0, a.size() - 1){ heap.push((pos){1, i}); } while (m --){ pos now = heap.top(); heap.pop(); printf("%d ", f(now.x, a[now.type], b[now.type], c[now.type])); heap.push((pos){now.x + 1, now.type}); } puts("/n"); return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 成人男女视频 | 海角在线观看91一区二区 | 色综合网在线观看 | 国产又粗又爽又深的免费视频 | 久久国产精品区 | 成人在线视频一区 | 久久久久久久久淑女av国产精品 | 日本特级a一片免费观看 | 99国产精品白浆在线观看免费 | 久久精品视频1 | 久久久久久亚洲综合影院红桃 | av在线一区二区三区四区 | 一级性生活免费视频 | 午夜精品久久久久久毛片 | 国产精品午夜在线 | 精国产品一区二区三区四季综 | 国产午夜精品一区二区三区四区 | 欧美精品一区自拍a毛片在线视频 | 欧美一级免费在线观看 | 九九热精品视频在线免费观看 | 久久精品毛片 | 精品一区二区三区在线视频 | 特级毛片全部免费播放器 | 久久网站热最新地址4 | 成人午夜久久 | 思思久而久而蕉人 | 污片在线观看视频 | 精品一区二区久久久久久按摩 | 精选久久 | 成人免费福利视频 | 色综合久久久久久久久久久 | 毛片在线免费视频 | 在线免费观看毛片视频 | 久久99精品久久久久久园产越南 | 日日草夜夜草 | 一级免费| 亚洲天堂在线电影 | 国产高潮国产高潮久久久91 | 亚洲第一成网站 | 亚洲一区二区免费视频 | 国外成人在线视频 |