pku acm 1019

#include <iostream>#include <cstdio>#include <string>#include <algorithm>#include <deque>#include <limits>#include <cmath>using namespace std;//求10進位正整數k的位元,如123為3位int nobits(int k){int count = 0,t = k;while(

pku acm 1064

二分搜尋的應用#include <iostream>#include <cstdio>#include <iomanip>using namespace std;int intCables[10002];//單位cmbool numberCuts(int index,int k,int length)//cm單位{long long lnums = 0;for (int i = 0; i < index; ++i){lnums += intCables[

HashTable的一個詳細實現

註:修改完善於一個粗糙版本http://blog.csdn.net/aishen944/article/details/14835161,修改了原文代碼中的錯誤2,主要解決了在擴容時hash效率較差的問題 #ifndef _HASHTABLE_H #define _HASHTABLE_H struct hashtable; struct hashtable* hashtable_create(unsigned long size, unsigned

pku acm 1032

有兩種方法求解,(1)遞迴分解,這種方法很好想,但是逾時(2)分析題目,得出一些基本規律。(參考了他人的想法)1,    a[1] > 1Proof: If a[1] = 1, a[t] could be replacedby a[t] + 1 and a[t]+1 > a[t] * 1. 2, 1 <= a[i+1] – a[i] <= 2Proof: If exists i make a[i+1] – a[i] >2, then a[i], a[i+1]

pku acm 1035

//Spell checker#include <iostream>#include <cstdio>#include <string>#include <set>using namespace std;set<string> dic;string dictxt[10005];int index = 0;bool isInDic(string& s){set<string>::iterator it;it =

pku acm 1009

-)常規解法,Time Limit Exceeded設一個點x與周圍8個點相減後絕對值的最大值為edv值。思想:1)同一行中的相鄰點x1,x2,如果x1已經求得它周圍的8個點那麼對於x2而言只需要計算另外3個點就可以了。   邊界情況就是:對於左邊界的點必須求周圍8個點2)當兩個相鄰點x1,x2的edv值都是0時,檢查是否存在接下來很多點值都相等的情況,這那麼可以加速。儘管使用了以上兩種技術但是速度仍然不夠快,平台通不過。#include <iostream>#include

pku acm 1023

#include <iostream>#include <cstdio>#include <string>#include <limits>#include <cmath>#include <algorithm>using namespace std;class Funk{public:typedef long long LL;typedef unsigned long long ULL;private:int nbits;

指向類的資料成員和函數指標

 指向類成員的指標在C++語言中,可以定義一個指標,使其指向類成員或成員函數,然後通過指標來訪問類的成員。這包括指向屬性成員的指標和指向成員函數的指標。à 指向資料成員的指標在C++語言中,可以定義一個指標,使其指向類成員。當屬性成員為靜態和非靜態時,指標的使用也有不同。其中,指向非待用資料成員的指標定義格式如下:1.    <資料類型> <類名>::*<指標名> [ =

pku acm 1095

Trees Made to Order#include <iostream>#include <cstdio>#include <string>using namespace std;const int LEN = 30;class OrderTree{private:static int kinds[LEN];//kinds[i]表示有i個結點情況下共有多少種不同的樹static int

Jdk如何?Iterator介面?

以下為一熱心網友自己通過匿名類的形式實現Iterator介面,代碼如下所示:import java.util.Iterator;public class OurArrayList<E> implements Iterable<E> { private E[] datas; private int size; public OurArrayList() { this(16); }

pku acm 1065

//貪心演算法 #include <iostream>#include <cstdio>#include <list>#include <algorithm>using namespace std;typedef pair<int,int> PINTINT;bool cmp1(PINTINT p1, PINTINT p2){if (p1.first < p2.first)return true;if (p1.first >

pku acm 1061

解題思想:(x + step * m) % L = (y + step * n) % L則(x - y + step * (m - n) ) % L == 0  || ( y - x + step * (n - m)) % L == 0則(x - y + step * (m - n) ) = p * L  || ( y - x + step * (n - m)) = p * L若m > n則相當於求 step * (m - n) + p * L = y - x

pku acm 1077

非常經典的8數位問題,主要採用的演算法是人工智慧中的“有序搜尋演算法”,也有人稱之為A演算法。#include <iostream>#include <cstdio>#include <algorithm>#include <set>#include <string>using namespace std;const int LEN = 9;struct PStatus{string pos;//位置資訊int index;//'x'

字元特性char_traits定義,及其特化版本char_traits,char_traits

// iosfwd standard header#if _MSC_VER > 1000#pragma once#endif#ifndef _IOSFWD_#define _IOSFWD_#include <cstdio>#include <cstring>#include <cwchar>#include <xstddef>#ifdef _MSC_VER#pragma pack(push,8)#endif /*

pku acm 1028

#include <iostream>#include <cstdio>#include <string>#include <stack>using namespace std;class Navigation{private:stack<string> fward;stack<string> bward;string curl;//current urlpublic:Navigation(string url):curl(

pku acm 1077(雙向寬度優先解法及HashTable最佳化演算法)

原文來自:http://hi.baidu.com/gropefor/home 的部落格中,代碼寫的非常精巧,強烈推薦。在第二版的最佳化中使用了HashTable來加速查詢。這兩個代碼使我瞭解了兩種演算法,一種是雙向寬度優先搜尋,另一種就是實際的HashTable的應用,以前一直聽說HashTable很有用,但是從來沒有在自己實際的代碼中運用過,這一次開眼了。代碼一:雙廣搜 

pku acm 1080

#include <iostream>#include <cstdio>#include <string>#include <algorithm>#include <map>using namespace std;map<string,int> dicm;//字典void myinit()//初始化字典{dicm.insert(make_pair("AA",5));dicm.insert(make_pair("AC",-1)

cstdarg可變參數列表

文章目錄 Parameters va_listType to holdinformation about variable argumentsThis type is used as a parameter for the macros definedin cstdarg to retrieve the additional arguments of a

pku acm 1087

第一次碰到最大流的問題。雖然我知道最大流的演算法,但是砬到這題是根本沒想到用最大流來求解。解法參考了http://www.cppblog.com/NARUTOACM/archive/2010/03/01/108680.html。解決此題的關鍵在於流圖的建立:1,源點Source為0,sink結點為T2,1 - m為要求m個不同的裝置3,m +1, m + n為室內已有的 n 個插頭receptacles4,m + n + 1 到

Operator new函數

文章目錄 ParametersReturn value operator newvoid* operator new (std::size_t size) throw (std::bad_alloc);void* operator new (std::size_t size, const std::nothrow_t& nothrow_constant) throw();void* operator new

總頁數: 61357 1 .... 12831 12832 12833 12834 12835 .... 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.