11054 – Wine trading in Gergovia

描述:水題,不解釋#include <cstdio>#include <cstdlib>int num[100010];int main(){ //freopen("a.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { if(!n) break; unsigned long long int sum=0; for(int i=0;

10026 – Shoemaker’s Problem

描述:就是性價比問題,誰的性價比高誰就優先,如果一樣,就按照工作的順序優先#include <cstdio>#include <cstdlib>#include <cstring>int cmp(const void *p1,const void *p2){ if(((int *)p1)[1]*((int *)p2)[0]>((int *)p1)[0]*((int *)p2)[1]) return 1; else if((((int *)p1

10382 – Watering Grass

描述:區間選取問題的變換問題#include<cmath>#include<cstdio>#include<cstdlib>int cmp(const void *p1,const void *p2){ if(((double *)p1)[0]>((double *)p2)[0]) return 1; else if(((double *)p1)[0]<((double *)p2)[0]) return -1; else {

10720 – Graph Construction———-水過了!!

 描述: 我們把序列排成不增序,即d1>=d2>=...>=dn,則d可簡單圖化若且唯若d'=(d2-1, d3-1, ... d(d1+1)-1, d(d1+2), d(d1+3), ... dn)可簡單圖化。這個定理寫起來麻煩,實際上就是說,我們把d排序以後,找出度最大的點(設度為d1),把它和度次大的d1個點之間連邊,然後這個點就可以不管了,一直繼續這個過程,直到建出完整的圖,或出現負度等明顯不合理的情況。舉例:序列S:7,7,4,3,3,3,2,1  刪除序列S的首項 

10382 – Watering Grass———–(題目簡單)卡精度啊!!wa了8次!

精度這個東西好神奇~如果判斷一個double的數大於0,直接讓這個double跟一個很小的數的負數比較大小~!!!!!!!!!#include<cstdlib>#include<iostream>#include<cstdio>#include<cmath>#include<set>#include<cstring>#include <algorithm>#define N 10005#define MIN

10670 – Work Reduction

描述:用最少的錢把n降到m,l代表輸入有多少種可能,每一種可能第一個數代表n減少一需要花費多少,第二個數代表減少一半需要花費多少,然後統計一下就可以了#include<cstdio>#include<cstdlib>#include <cstring>struct State{ int num; char str[20];};State s[110];int cmp(const void *p1,const void *p2){

poj3013—–spfa演算法(難題)

/*題意:給出n個點,m個邊。給出每個點的權值,每個邊的權值。求建立一棵樹,root=1,求這棵樹的最小費用,費用=樹上每條邊*子樹中各頂點的權值。思路:root的權值是沒用的,而其餘節點是必須用的,每條邊*子樹中各定點的權值=各個點*點到根的最短路,於是轉化成了root到各個點的最短路。*/#include<cstdlib>#include<iostream>#include<sstream>#include<cstdio>#include<

10177 – (2/3/4)-D Sqr/Rects/Cubes/Boxes?

#include <cstdio>long int xx(int x){ long long int sum(0); for(int y=1; y<=x; y++) sum+=y*y*y*y; return sum;}long int xxx(int x){ long long int sum(0); for(int y=1; y<=x; y++) sum+=y; return sum;}int main()

POJ 2286 HDU 1667 ZOJ 2396 The Rotation Game IDA*迭代加深搜尋

The Rotation GameTime Limit: 15000MS Memory Limit: 150000KTotal Submissions: 3819 Accepted: 1262DescriptionThe rotation game uses a # shaped board, which can hold 24 pieces of square blocks (see Fig.1). The blocks are marked with symbols 1, 2 and 3,

755 – 487–3279

#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#define N 100100using namespace std;int fcmp(const void *p1,const void *p2){ return strcmp((char*)p1,(char*)p2);}int main (){ //freopen("a.txt","r",

POJ3662 Telephone Lines 二分+最短路

 Telephone LinesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3468 Accepted: 1245DescriptionFarmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the

10061 – How many zero’s and how many digits ?

#include <iostream>#include <cmath>#include <cstring>using namespace std;long su(long a,long b,long c){ long d(a); while(d%b==0&&d!=1) { d=d/b; c++; } return c;}void sc(long a,long b,long

HDU 4115 Eliminate the Conflict 2-sat

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<stack>#include<map>#include<algorithm>using namespace std;const int MAXE=10000002;const int MAX=20009;int vis[10

UVa 10603 – Fill

倒水問題,bfs+雜湊,需要將每一步的總倒水量全部存起來,最後再排一次序,將小於等於d 的最大的d及其匹配的總到水量輸出即可。代碼如下:#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;const int MAXSIZE

10720 – Graph Construction

描述:因為是簡單圖,所以先判斷角度和是否為偶數,然後再需要用優先隊列,從大到小進行排除#include <iostream>#include <cstdio>#include <cstdlib>#include <queue>using namespace std;priority_queue <int> p;int num[10010];int main(){ // freopen("a.txt","r",stdin);

UVa 321 – The New Villa

本來想用bfs(房間的狀態)+dfs(燈的狀態)+雜湊的,但最後發現同一個房間可以反覆進好幾次以實現部分燈的開關,這樣的話每一步都dfs其代價就會很大。參考了其他人的程式,用純 bfs+雜湊(選項組共有10*2^10) 足矣。代碼如下:#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <cstdio>#include &

116 – Unidirectional TSP

描述:實際就是從這個數組找最小,狀態方程是:s[i][j]+=min(min(s[a][j+1],s[b][j+1]),s[c][j+1]);但是難得不是這,而是尋找一條路徑滿足行座標盡量的小,只能從右往左找了#include <cstdio>#include <cstring>int min(int a,int b){ if(a>b) return b; else return a;}int main(){ //freopen("a.txt","

UVa 532 – Dungeon Master

BFS ~不解釋。代碼如下:#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;const int MAXSIZE = 1000003;int l, r, c, fl, fr, fc, dis[MAXSIZE];int p1

10718 – Bit Mask

描述:題意很簡單,可是如果要從L到U之間用 | 遍曆的話會逾時,只能換種思路了#include <cstdio>#include <cstdlib>int main(){ // freopen("a.txt","r",stdin); int n,l,u; unsigned int m; while(scanf("%d%d%d",&n,&l,&u)!=EOF) { m=0; for(int i=

10098 – Generating Fast

描述:很簡單的題目,按照劉汝佳書上的方法寫一遍就是了,然後就可以AC代碼一:#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;void print_permutation(char *p,char *q,int len,int cur){ int i,j; if(cur==len) printf("%

總頁數: 61357 1 .... 13813 13814 13815 13816 13817 .... 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.