STL bitset 的總結

/*hdu 2051題意:將一個十進位數轉換成位元*/#include <iostream>#include <bitset>using namespace std;int main(void){int n;bitset<10> res = 0;//bitset<10> res = 1 只能使 res[0] = 1;while(cin >> n){res = n;int index =

hdu 2602 0 – 1背包

/* 好久沒有用java寫了。代碼寫的好醜的,簡單的0 - 1背包 DP[i][j]表示前i個物品,背包容量為j的最優值狀態轉移方程為DP[i][j] = max(DP[i-1][j] , DP[i-1][j-v[i]] + w[i]);時間複雜度N*V , 空間複雜度N*V所以虛擬碼如下:for i = 所有物品for j = V to v[i] dp[j] = max(dp[j] , dp[j-v[i]] + w[i]);空間最佳化到一維V */import

hdu 1114 完全背包

/* 完全背包,且是恰好裝滿,求最小价值,初值 dp[0]=0,dp[i]=Max( 1<=i<=W ) 狀態轉移方程 dp[j]=min(dp[j],dp[j-we[i]]+va[i]) 最後只要dp[W]!=Max 就有最優解! */import java.io.*;import java.util.*;public class Main{public static void main(String[] args){ Scanner cin = new

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3403

/*這樣的水題把我卡的好慘的,看來不夠細心啊*/#include <iostream>#include <cstdio>#include <cmath>typedef long long LL;using namespace std;const long long year = 18382;//LL ye[] = {1, 9, 36, 100, 225, 441, 784, 1296, 2025, 3025, 4356, 6084};int

Hat’s Fibonacci hdu1250

#include<stdio.h>//一開始是這個錯誤        //  2194910 2010-03-16 21:10:26 Runtime Error          //(STACK_OVERFLOW) 1250 0MS 1240K 681 B C 悔惜晟 int num[10000][251];//這個不能定義在main()函數中會造成以上的錯誤 int main() {    int i,j,n;    num[1][0]=1;    num[2][0]=1;   

1160 hdu(最大遞增子序列)

#include<iostream>//2307385 2010-04-07 18:55:39 Accepted 1160 15MS 256K 1004 B C++ 悔惜晟 #include<cstdio>#include<algorithm>using namespace std;struct stu{ int w; int s; int num;}df[1005];int cmp(stu a, stu b){ if(a.w == b.w)  return

FATE hdu 2159 二維的完全背包

/*以下分析有參考Baidu 的,剛開始學背包,感覺不順手啊。二維的完全背包,狀態轉移方程:dp[i][j] = max(dp[i][j], dp[i - df[t].care][j - 1] + df[t].expr)dp[i][j] 消耗i的忍耐度獲得的最大經驗值,只要dp[i][s] >= n 就可以找到答案dp[i][j]表示殺i個怪剩j忍耐值獲得的最大經驗值 狀態方程:dp[i][j] = max(dp[i][j], dp[i - 1][j - df[t].care] + df[

最少攔截系統 hdu 1257

//一開始題目讀錯5 7 3 5 1 2輸出地應該為2的,一開始題目讀的認真,因為是求最大的連續的遞減子序列#include<iostream>//2313056 2010-04-08 17:47:13 Accepted 1257 15MS 348K 629 B C++ 悔惜晟 #include<algorithm>using namespace std;int num[100005];int main(){ int n, count, i; int b[10005]; 

飯卡 hdu2546

http://acm.hdu.edu.cn/showproblem.php?pid=2546// 很想0 1背包的問題,可是又有很大的變形,一開始以為是貪心,寫了一個好囧的代碼,wrong// 又寫了一個不是很熟悉的0 1 背包, 又wrong。好好努力!! #include<iostream>//2251214 2010-03-26 18:00:08 Accepted 2546 31MS 304K 557 B C++ 悔惜晟

hdu 1171多重背包Big Event in HDU

/*多重背包,其實對於這部分的內容不是很理解的,但是還是做對了,很奇怪的*/#include <iostream>#include <cstdio>#include <algorithm>using namespace std;const int N = 55;int main(){int n;int val[N], kind[N];int dp[100000];while( cin >> n){if(n < 0)break;int sum

Hat’s Words hdu 1247(字典樹 map)

/* 搞了一個早上,終於搞出來了。一開始以為字典樹的hash很簡單, 可是一寫才發現有很多的細節要注意 */#include<iostream>//2561185 2010-06-28 11:41:12 Accepted 1247 31MS 7364K 1977 B C++ 悔惜晟 #include<cstdio>#include<cstring>using namespace std;struct node{ struct node *child[26]; 

ubuntu初體驗

由於ubuntu和windows的編碼方式不同ubuntu是UTF—8,windows是GBK,所以在ubuntu下開啟windows下的一些txt檔案等,裡面會是亂碼,需要進行簡單設定 設定中文環境單擊主菜單中的“系統(System) --> 系統管理(Administration) --> 語言支援(language support)”。在“支援的語言”列表中找到“漢語(Chinese)”,在右端打上勾。同時將預設語言修改為“漢語(Chinese)”並勾選“啟用複雜字元輸入支援(

ACboy needs your help again! hdu1702

#include<iostream>//完全類比隊列和棧 #include<string>using namespace std;const int MAX = 100005;struct stack{ int top; int a[MAX];}s;struct queue{ int top; int base; int a[MAX];}ss;void push(int a){ s.a[s.top++] = a;}void push1(int

全排列next_permutation的用法(稍微有點改動)

/*分析next_permutation函數執行過程: 假設數列

最大子矩陣 hdu 1559

//題目的意思很簡單,而且給我們的時間10秒,一開始用了很笨的方法,直接類比,逾時//改了之後效率明顯升高#include<iostream>//2321883 2010-04-10 11:57:25 Accepted 1559 125MS 4156K 623 B C++ 悔惜晟 #include<cstdio>#include<string>using namespace std;int num[1001][1001];int main(){ int t,

hdu 2844 Coins 多重背包最佳化 很好

/*下面給出O(log amount)時間處理一件多重背包中物品的過程,其中amount表示物品的數量:procedure MultiplePack(cost,weight,amount)if cost*amount>=VCompletePack(cost,weight)returninteger k=1while

hdu 1075 map 的應用可以字串的hash

/* 好強大的STL。但是為何效率不高呢?看來字串完全可以這個hash了*/#include<iostream>//2524740 2010-06-07 23:18:42 Accepted 1075 1656MS 37584K 631 B C++ 悔惜晟 #include<cstdio>#include<map>#include<string>using namespace std;map<string, string> df;int

zoj 1109 我又學了一招

/* Language of FatMouse--------------------------------------------------------------------------------Time Limit: 10 Seconds      Memory Limit: 32768 KB --------------------------------------------------------------------------------We all know

hdu 2108 判斷凹包還是凸包

/*對於連續的三個點p0,p1,p2,另向量a=p1-p0,b=p2-p1若是凸多邊形,那麼b相對於a一定是向逆時針方向旋轉的判斷兩向量的旋轉方向,可以使用向量的叉積 a×b = x1×y2 - x2×y1a×b > 0 b在a的逆時針方向a×b = 0 b平行於a(共線)a×b < 0 b在a的順時針方向要注意的是,對於最後一個點pn,還要和起始的兩個點p0,p1判斷一次。*/#include<iostream>using namespace std;struct

hdu 3347 Calculate the expression

/*這是胡大牛給我們的講座Orz*/#include <iostream>#include <sstream>#include <map>#include <string>using namespace std;map<string, int> df;int main(){int t;cin >> t;while(t--){int n;cin >> n;string a, b;int

總頁數: 61357 1 .... 17847 17848 17849 17850 17851 .... 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.