poj2442 Sequence(堆)

#include <stdio.h>#include <string.h>#include <stdlib.h>int T,m,n;int a[2010];int b[2010];int hs;int cmp(const void* x,const void* y){return *((int*)x)-*((int*)y);}void shiftdown(int i){int last_not_leaf=(hs-2)/2;//最後一個非葉子節點int

poj2456 Aggressive cows (二分)

#include <stdio.h>#include <stdlib.h>int N,C;int a[100000];int cmp(const void* x,const void* y){return *((int*)x)-*((int*)y);}int can_put(int x){int i;int count=1;int t=a[0];for(i=0;i<N;i++){if(a[i]-t>=x){t=a[i];count++;if(count>

二分圖最大獨立集

       二分圖最大獨立集=點數n-二分圖最大匹配。知道這個公式後,這道題就很easy了,,是一道裸題,最基本的二分圖最大獨立集,,圖都是直接建好得。。。題目:Girls and BoysTime Limit: 5000MS Memory Limit: 10000KTotal Submissions: 7452 Accepted: 3242DescriptionIn the second year of the university somebody started a study on

Boost xml解析之菜鳥版

1.準備工作:環境: visual studio 2010 /boost:boost_1_54_0建立Application什麼的不做贅述,但是注意 如果需要引用Boost庫中的lib 需要在屬性properties的VC++ Directories中的Include Directories 中加入Boost的路徑待解析xml檔案:text.xml<students> <student id="1"> <name>張三</name>

poj2408 Anagram Groups

#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct tWord{char word[30];char sword[30];}Word;typedef struct tInfo{int c;char word[30];char smallest[30];}Info;Word w[30001];Info in[30001];char* end="_";int gc;int

NYOJ 451 組合數學 錯排

       水了一道關於組合數學的題,,算是做的第一道組合數學的題吧。。。。。。。。題目:光棍節的快樂時間限制:1000 ms  | 

POJ 1496 Word Index || POJ 1850 Code

/*本質:從N個數中取出M個數的組合思想,C(n,m)=C(n-1,m-1)+C(n-1,m)。*//*EP:字串長度是5,分成2部分,第一部分是長度從1到4的和(C(26,1)+C(26,2)+C(26,3)+C(26,4));*//*第二部分是對應的每一位小於該符號對應的字串個數。*/Source CodeProblem: 1496 User: imutzcyMemory: 208K Time: 0MSLanguage: C++ Result: AcceptedSource

判斷迴文愚蠢版

class Solution {public:    int minCut(string s) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int a = froml(s);        int b = fromr(s);        return a>b?b:a;    }        int froml(string s){

poj1018 Communication System (枚舉+貪心)

        分類上說是個動態規劃,但是沒有最優子結構啊,硬要說是動態規劃的話,只不過是開數組記了點資料而已,好像沒有那麼典型的轉移方程。其實這個枚舉+貪心就可以了,枚舉頻寬的下限,然後計算對每個下限B/P的最大值。比如如果頻寬下限是band,那麼顯然,在每組裝置裡選擇的某個裝置device,首先該裝置的頻寬必須大於等於band,然後價錢當然就越低越好了,這個地方就是個貪心選擇.......#include <stdio.h>#include

HDU 4006 The kth great number(STL)

/*用STL set  去維護集合的大小為k*/Problem : 4006 ( The kth great number )     Judge Status : AcceptedRunId : 6313274    Language : C++    Author : CherryChouCode Render Status : Rendered By HDOJ C++ Code Render Version 0.01

九度OnlineJudge之1468:Sharing

題目描述:To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, "loading" and "being" are stored as showed

poj3267 The Cow Lexicon (動態規劃)

        比較簡單的動態規划了,如果用dp[i]表示str串從i位置開始匹配需要刪掉的字母數量,那麼對i位置,可以做兩種選擇,用i處的字元進行匹配,或者不用i處的字元匹配。        1.如果不用i處匹配,狀態轉化比較好寫:dp[i]=dp[i+1]+1,也就是將i處的字元刪掉(代價為1),然後繼續從i+1位置開始匹配。       

碼農的書單

電腦程式設計藝術演算法導論代碼大全編譯原理人月神話軟體隨想錄C程式設計語言C++ PrimerC++程式設計語言C++沉思錄Effective C++More Effective C++Java編程思想STL源碼剖析設計模式設計原本程式員修鍊之道離散數學及其應用電腦程式的構造和解釋深入理解電腦系統架構之美編程珠璣駭客與畫家代碼之美UNIX編程藝術人件編程之美C和指標C陷阱與缺陷C專家編程C++ Primer PlusC++編程思想Essential C++C++標準程式庫具體數學深入淺出MFC 

POJ 1325 二分圖最小點集覆蓋

        一道貌似難題的水題,,不過我還是想了兩個多小時。首先理解題意就理解了好久,,然後又想建圖又想了好久,,最後發現建過圖之後就是一道裸的二分圖最小點集覆蓋。。。。悲催。。。題目:Machine ScheduleTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 8033 Accepted: 3409DescriptionAs we all know, machine scheduling is a very

九度OnlineJudge之1001:A+B for Matrices

題目描述:    This time, you are supposed to find A+B where A and B are two matrices, and then count the number of zero rows and columns.輸入:    The input consists of several test cases, each starts with a pair of positive integers M and N (≤10) which are

文字常量區、字串常量、地址

可以:#include <stdio.h>int main(void){char str[8] = {0};str[0] = *"jiang";printf("%s\n", str);return 0;}輸出結果是:j  2012/5/16 更新補充一個例子(正確):#include <iostream>using namespace std;int main(void){cout << "0123456789"[5] <<

括弧匹配(棧實現)

 #include <cstdio>#include <iostream>using namespace std;#define MAXSIZE 20typedef struct {char *base;char *top;int stacksize;}SqStack;void InitStack(SqStack &S){S.base = (char *)malloc( MAXSIZE * sizeof(char) );if(S.base ==

九度OnlineJudge之1464:Hello World for U

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h    de     ll      rlowoThat is, the characters must be printed in the original order, starting

最大公約數(Greatest Common Divisor ) 與 最小公倍數(Lowest Common Multiple )

今天開始準備做個系列,專門存快速簡潔的演算法代碼。當然了,共用是必需的! 如果只用到 gcd 就只需貼第一個函數,要用到 lcm 就全貼上。int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){return a / gcd(a, b) * b;} 2012/5/11

HDU 1800 貪心

這個題目不同於飛彈攔截,這個可以調整順序的,所以我們可以通過統計每個數位出現次數,出現次數最多的就是ANS比如 1 2 4 5 4 ,其中4出現了兩次,這個次數是最多的了,所以答案就是2由於數字區間高達三十位元,用普通的區間尋找絕對TLE,這個時候,用字典樹是個好選擇,統計下每個字串的出現次數是字典樹的典型應用#include<stdio.h>#include<string.h>#include<stdlib.h>#define val 3005struct

總頁數: 61357 1 .... 21017 21018 21019 21020 21021 .... 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.