HDU-1280 HASH

看來我得擺脫思維定勢,最開始竟然是用堆做的,並且做錯了==!/* * hdu-1280 * mike-w * 2012-4-14 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_N 3333#define MAX_VALUE 11111int f[MAX_N],g[MAX_VALUE];int N,M;int main(void){#ifndef

PKU2262 Goldbach’s Conjecture 數論-素數

PKU2262 Goldbach's Conjecture 用篩選法產生素數表prime[MAX]。。。 之前一直把最簡單的試除法當做篩選法來用,還認為效率很高,  然後這題就一直一直time limit exceed    1、試除法 用 n 除以 2-sqrt(n),有一個能除盡就不是素數,否則是素數。 時間複雜度:O(sqrt(n)) 2、素數判斷法 這種方法是對上面方法的改進,上面方法是對 2-sqrt(n)之間的數進行判斷是否能除盡,而

hdu1251 統計難題 字典樹

 hdu 1251 統計難題 字典樹的解釋及模板 背下來..  #include<iostream>using namespace std;struct trie{int num;bool isword;trie *child[26];trie(){for(int i=0;i<26;i++)child[i]=0;num=0;isword=0;}} root;void insert(char *x){int k=0;trie *p=&root;while(x[k]!='\

HDU-1166 線段樹

線段樹體現了一種分治的思想——將分治思想理解好,線段樹就比較好寫。/* * hdu-1166 * mike-w * 2012-4-8 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 666666#define MAX_N 55555#define BUF_SIZE 50typedef struct _tnode{int l,r,sum;}tnode;tnode

程式員裝逼指南

程式員嘛,外行人看起來已經是不可理解的奇怪生物了,自然也沒必要跟他們再裝逼所以呢,如何對其他程式員裝逼就是一門很有學問的事了 ----------------------------------------------------  一.準備工作“工欲善其事必先利其器。”1.電腦不一定要配置高,但是雙屏是必須的,越大越好,能一個橫屏一個豎屏更好。一個用來查資料,一個用來寫代碼。總之要顯得資訊量很大,效率很高。2.椅子不一定要舒服,但是一定要可以半躺著。3.大量的便簽,各種的顏色的,用來記錄每天要

swap()函數效率對比

在網上看代碼,偶然間發現了swap()的另一種寫法,利用了位元運算,不是很好理解——至少不如樸素的swap()那麼直接。作為OIer,效率至上,我便對比了樸素swap()和“神奇”swap()的效率。測試代碼如下。/* * swap() test * mike-w * 2012-4-14 */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<time.h>#define

hdu1075 What Are You Talking About-字典樹

hdu1075 What Are You Talking About  模板是對了,但是題目的格式沒弄清楚,然後換了一個主函數ac了。。。。 #include<iostream>using namespace std;struct trie{bool isword;char word[11];trie *child[26];trie(){for(int i=0;i<26;i++) child[i]=0;isword=0;word[0]='\0';}} root;void

也許這30句話會幫到你

因為自己是C++黨,所以這篇文章主要面對C++的OIer0.比賽前一天晚上請準備好你的各種證件,事先查好去往考場的路線1.比賽之前請先調整你的螢幕解析度到你喜歡的大小2.比賽之前請把編譯器的字型調為你平時慣用的字型,尤其是注意這種字型中的逗號,點,1,l這種易混淆的字是不是區分明顯3.在不影響視野的情況下,請將字型大小儘可能調大,方便查錯4.請將題目通讀完以後,再開始深入思考你認為最容易的一道題5.即使這道題再容易,也不要著急寫代碼,請先明確自己每一步要幹什麼後,再開始寫,輕敵會是你最大的錯誤6

hdu1671Phone List – 字典樹

hdu1671Phone List簡單的字典樹空間換時間,花銷超大,,,如果有多組資料的話 呃那用完就釋放吧 , 恩 。#include<iostream>using namespace std;struct trie{bool exist;int num;trie *next[10];trie(){exist=0;num=0;for(int i=0;i<10;i++) next[i]=0;}} *root;bool insert(trie *p,char *s){int k=

HDU-2063 二分圖匹配

我很困惑——不懂/* * HDU 2063 過山車 * 二分圖匹配 * 請教:為什麼注釋裡的語句加進去後就WA? */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 1111int f[SIZE][SIZE];int tag[SIZE];int match[SIZE];int K,M,N;int read(void){int i,t1,t2;scanf("%d",&K)

hdu3999 the order of a tree – BST二叉搜尋樹的前序走訪

hdu3999 the order of a tree二叉搜尋樹(BST)跟字典樹相比,BST佔用的資源少很多所以要不要釋放資源都無所謂?還是養成一個好習慣吧,,#include<iostream>using namespace std;struct BST{int num;BST *lson,*rson;BST(){num=-1;lson=rson=0;}} ;BST *insert(BST *p,int x){if(!p){p=new

HDU-2191 多重背包

下一次寫我要把代碼模組化一下,像DD那樣把各種背包過程分離出來。/* * HDU-2191 紀念512 * mike-w * 2011-10-15 * --------------------- * 簡單的多重背包 * 為死者默哀... */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 111long p[SIZE],w[SIZE],c[SIZE];long

hdu2037今年暑假不AC 貪心

hdu2037今年暑假不AC第一次看貪心感覺很像動態規劃。。。。。。。。。。。。首先對n中節目排序例如題中資料排序後為0 71 32 93 43 84 145 106 128 1810 1515 1915 20之後就是貪心的思想了用最少的時間看最多的節目#include<iostream>using namespace std;struct TV{int s,e;bool flag;} S[101];bool cmp(TV a,TV b){if(a.s==b.s) return a.

hdu3791二叉搜尋樹

hdu3791二叉搜尋樹  又是二叉搜尋樹的前序走訪。 1.建樹會順序影響整棵樹的形狀2.記得釋放資源3.可以用雙重指標和引用最佳化程式。。 代碼某些printf() 是之前設定的斷點,,可以無視之#include<iostream>using namespace std;struct BST{char ch;BST *lson,*rson;BST(){ch=0; //不可能的字元 lson=rson=0;}} *root;BST *insert(

hdu 1875暢通工程再續-prim最小產生樹

hdu 1875暢通工程再續 鄰接矩陣中的資料必須初始化完整 #include<iostream>#include<math.h>using namespace std;const double INF=1000000000.0;double mp[100][100]; struct point{int x,y;} P[100];double prim(int N){int i,j,k,mark=1;double min,length;for(i=1;i<=N;i+

HDU-1495 BFS

此題為經典的BFS問題。為了讓代碼簡潔一點,我犧牲了效率——話說我不知道效率具體犧牲在哪裡了==! /* * hdu-1495 非常可樂 * mike-w * 2012-3-16 ********************* */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 120#define Q_SIZE 10000int N,M,S,half;int

HDU-2037 貪心

/* * hdu-2037 * mike-w * 2012-4-15 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 128int f[MAX_SIZE][2];int N;int comp(const void *e1, const void *e2){return *((int*)e1+1) - *((int*)e2+1);}int

tyvj-1084 簡單DP

不知道為什麼這個題目被分到了搜尋的分類中==!類似於數塔的做法。/* * tyvj-1084 數字三角形 * mike-w * 2012-3-10 * ================= */#include<stdio.h>#include<string.h>#include<string.h>#define MAX_SIZE 30int f[MAX_SIZE][MAX_SIZE];int opt[MAX_SIZE][MAX_SIZE];int n,x,y;

HDU-2955 背包問題

/* * hdu-1588 roberies * mike-w * 2012-5-13 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_M 11111float opt[MAX_M];int main(void){#ifndef ONLINE_JUDGEfreopen("in","r",stdin);#endifint ncase,nbank;int i,j,m;float

HDU-2952 BFS

/* * counting sheeps * mike-w * 2012-4-30 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * 題目描述很有意思 * 為什麼失眠?本人缺覺==! */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 128#define Q_SIZE (MAX_SIZE*4)char

總頁數: 61357 1 .... 20997 20998 20999 21000 21001 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.