原创 [priority_queue]
# include<iostream> #include<queue> using namespace std; int main ( ){ priority_queue<int> pque; pque.push(3); pque
原创 優先隊列:奶牛喝汽油
http://poj.org/problem?id=2431 Xavier養的一羣奶牛劫持了一個卡車,並向叢林中逃亡。由於奶牛們不會開車,卡車不幸地撞上了叢林中的一塊岩石,並撞破了油箱。於是他們每行駛一個單位距離
原创 【動態規劃】P1164 小A點菜
#include<iostream> #include<cstring> #include<algorithm> using namespace std; #define MAXN 105 #define MAXM 10005 int
原创 [考前經驗]NOIP比賽寫代碼注意事項 -轉載
1.頭文件: 常用頭文件: <iostream> <cstdio> <cmath> <cstring> <cstdlib> cstdio包含sca
原创 [考前經驗]對拍
一、生成隨機數 (測試用,考試文件別用) [cstdlib] rand() rand()不需要參數,它會返回一個從0到RAND_MAX(最小爲32767)的任意整數。 如果你要產生0~10的10個整數,可以表達爲: int N = r
原创 [cstdlib] rand()
rand()不需要參數,它會返回一個從0到RAND_MAX(定義在stdib.h中,該值最小爲32767)的任意整數。 如果你要產生0~10的10個整數,可以表達爲: int N = rand() % 11; 這樣,N的值就是一個0~10
原创 [總結]2018 noip 考後總結
總結: 非技術問題 證件問題 考試大屏幕提示沒有仔細看 某個被趕出來的考生 沒有創建子文件夾!!不得包含其他文件!! 提交前沒有查freopen裏的文件名!! 自傲,審題不清(t2問下標最小的),沒有用極端數據測試程序 技
原创 算法的時間複雜度估算
數據範圍\時間複雜度 O(n) O(n^2) O(n^3) O(n * sqrt(n)) O(nlogn) 100 1e2 √ √ √ √ √ 1000 1e3 √ √ × √ √ 10000 1e4 √ √ × √ √ 100000 1
原创 [題] [NOIP2011] 統計單詞數
不用string 用string 方法對比 //1.1 不用string 純笨辦法 #include<iostream> #include<cstdio> #include<string> #include<cstring> using
原创 [bfs][題]抓住那頭牛,幫曾改後的
#include<iostream> using namespace std; int ap[100002][2]= {}; bool bl[100002]= {}; int main() { int head=0,tail=0,n,
原创 [動態規劃] 揹包問題 c++
5個物品的質量 int w1[6]={0,4,2,1,3,6}; 5個物品的價值 int v1[6]={0,60,30,10,50,70}; 最多能負重16,價值最大多少? cout<<"最多輸出:"<<list(w1,v1,6,
原创 [queue] c++優先隊列(priority_queue)用法詳解
#include<iostream> #include<queue> #include<algorithm> using namespace std; int main() { queue<int> b; b.push(1); b.
原创 [struct]典型例題 聲明 排序
任務1:按學生總分降序,總分一樣,按第一科成績降序 輸出學生姓名 #include <iostream> #include <algorithm> #include <string> using namespace std; stru
原创 [二分法] 在一個非降序列中,查找與給定值最接近的元素
/* 描述 在一個非降序列中,查找與給定值最接近的元素。 輸入 第一行包含一個整數n,爲非降序列長度。1 <= n <= 100000。 第二行包含n個整數,爲非降序列各元素。所有元素的大小均在0-1,000,000,000之間。 第三行
原创 [string] 數字與string相互轉換 c++
如何把數字轉換爲string? #include<iostream> #include<sstream> using namespace std; stringstream temp;//名字自己起 int main() {