Time of Update: 2018-12-03
/* hdu 1166 跟1754是一樣的 線段樹*/#include <cstdio>#include <cstring>#define maxn 50005using namespace std;struct Node{ int l,r,sum;}node[maxn*3];int T;int n;void build(int x,int y, int i){ node[i].l=x; node[i].r=y;
Time of Update: 2018-12-03
//貝神傑作,僅作記錄,以後學習#define GDIPVER 0x0110 //定義高版本的GDI+(1.1)#include <tchar.h>#include <windows.h>#include <ObjIdl.h>#include <stdio.h>#include <GdiPlus.h>#pragma comment(lib,"GdiPlus.lib")using namespace Gdiplus;#include
Time of Update: 2018-12-03
/* poj 2533 將每個數看做DAG圖上的一個節點 d[i]代表到i點的最長路徑 求所有d[i]中最大的那個 i點的前j個中,如果num[j]<num[i],即j到i點有向*/#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define maxn 1004int nums[maxn];int d[maxn];int
Time of Update: 2018-12-03
/* hdu 1176 DP 狀態轉移方程 d[i][j]=max(d[i+1][j],d[i+1][j-1],d[i+1][j+1]); 本來想用一維數組存的 ,但發現這樣做的話會導致使用到新更新的資料, 比如在第i秒,j-1的位置剛被更新,j要比較前一個狀態下三個位置哪個大 但是j-1位置已經是第i秒的了*/#include <cstdio>#include <algorithm>#include
Time of Update: 2018-12-03
/* CodeForces 131C 組合數學*/#include <cstdio>#include <cmath>using namespace std;__int64 cal(__int64 a, __int64 b){ __int64 tem=1; for(int j=1;j<=b; j++) { tem=tem*a/j; a--; } // printf("%d\n",tem);
Time of Update: 2018-12-03
/* hdu 2182 DP還是不熟練, dp[i][j]表示第i跳時,第j個座標點能吃到蟲子的最大值*/#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#define maxn 105using namespace std;int ins[maxn];int dp[maxn][maxn];int T;int ans;int n,a,b,
Time of Update: 2018-12-03
N皇后問題Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4933 Accepted Submission(s): 2252Problem
Time of Update: 2018-12-03
/* poj 3070 二分冪+矩陣乘法 要注意代碼的簡潔 把功能塊單獨寫個函數*/#include <cstdio>#include<cmath>#define mod 10000using namespace std;__int64 n;__int64 c[2][2];//__int64 f[maxn]={0,1};__int64 cal(__int64 a[][2],__int64 b[][2]){ __int64 sum;
Time of Update: 2018-12-03
/* hdu 2795 線段樹 在更新環出了問題 導致被修改子節點的父節點沒有更新 (最後導致逾時) 這裡我用了位元運算 但是沒有變快。。。反而慢了10ms; 教訓:發現有錯誤之後 測試構造的線段樹有沒有錯,再查線段樹是否在更新的時候更新不完全*/#include <cstdio>using namespace std;#define maxn 200006int h,w,n;int ans;int flag;struct Node{
Time of Update: 2018-12-03
輸入二叉樹的先序遍曆序列和中序遍曆序列,輸出該二叉樹的後序遍曆序列。(非建二叉樹版本)#include<iostream>#include<string>using namespace std;string preord, inord;void rebuild (int preleft, int preright, int inleft, int inright){int root, leftsize, rightsize;if(preleft <=
Time of Update: 2018-12-03
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 22481 Accepted: 7598DescriptionBackground The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the
Time of Update: 2018-12-03
已知一個按先序序列輸入的字元序列,如abc,,de,g,,f,,,(其中逗號表示空節點)。請建立二叉樹並按中序和後序方式遍曆二叉樹,最後求出葉子節點個數和二叉樹深度。#include<iostream>#include<queue>#include <cstdlib>#include <cstdio>using namespace std;typedef struct BiNode{char data;struct BiNode
Time of Update: 2018-12-03
#include <stdio.h>int main(){double x = 12.5;printf("%d\n",x);int y = 10;printf("%lf\n",y);}輸出:00.000000float x = 12.5;printf("%d\n", x);float: 1位符號位(s)、8位指數(e),23位尾數(m,共32位)double:
Time of Update: 2018-12-03
控制台單調的顏色只有黑白兩種,看起來多少難免有些單調。在沒學圖形化編程之前,每天看著控制台程式難免會枯燥無味。不過,利用SetConsoleTextAttribute函數可以設定控制台的前景色彩和背景色。閑言少敘,書歸正傳。①:(顏色可以混合,遵循配色原理)#include <windows.h>#include <iostream>using namespace std;int main(){ HANDLE hOut; hOut =
Time of Update: 2018-12-03
#include <cstdio>#include <highgui.h>int main(){IplImage *pImg = NULL;CvCapture *cap = cvCaptureFromCAM(0);char fileName[100];char key;int count = 0;while(1){pImg = cvQueryFrame(cap);cvFlip(pImg, NULL, 1);
Time of Update: 2018-12-03
/* hdu 1114 題目大概意思是把錢存在一個存錢罐裡面 給出空存錢罐的重量和裝錢後存錢罐的重量, 給出幾種貨幣的價值和重量,問你在不超過重量的情況下,貨幣價值的最小值 實際上就是一個背包問題,類似那個硬幣問題 用dp[i]表示需要湊足重量i需要的最少貨幣價值 在DAG圖上可以表示為確定起點DP[s]和終點dp[0],求最短路徑 dp[0]為0; */#include <cstdio>#include
Time of Update: 2018-12-03
開源3D遊戲引擎Irrlicht(鬼火)用法入門 趙剛 Irrlicht(中文名:鬼火)是著名的3D開源引擎之一,該3D引擎結構清晰,執行效率高,上手容易,無論是初學者學習3D遊戲引擎,還是用來開發規模較小的3D應用都是很不錯的選擇。 本文以Irrlicht 1.7.2 版(目前的最新版)為例,講解其在Windows系統中的用法。 首先需要在http://irrlicht.sourceforge.net/downloads.html 下載Irrlicht的SDK,1.7.2版的SDK尺寸為24
Time of Update: 2018-12-03
貪心類題目算出javabean的價值再排序/* 需要注意ja為0或者f為0的情況 */#include <iostream>#include <cstdio>#include <algorithm>#define INF 99999999#define maxn 1005using namespace std;struct Node{ double ja,f,price;}node[maxn];bool cmp(Node a,Node
Time of Update: 2018-12-03
/* hdu 1128 只要把不符合的都標記起來,再輸出沒有標記的就可以了 之前犯了個小錯誤 WA了*/#include <cstdio>#define maxn 1000000using namespace std;bool hash[maxn];int main(){ int sum; for(int i=1;i<=maxn;i++) { sum=i; int j=i;
Time of Update: 2018-12-03
/*這種線性探測再散列技術處理衝突的方法節省了空間,也縮短了時間*/#include<stdio.h>#include<memory.h>#define MAX 50021int f[MAX],g[MAX];int hash(int k){ int t=k%MAX; if(t<0) t+=MAX; while(f[t]!=0&&g[t]!=k) t=(t+1)%MAX; return t;}int