Hdu遞推求解專題練習(For Beginner)

在Hdu上是下面幾題:Hdu 2041 超級樓梯下面是解題報告(因為有的題有點水,和貼發)Hdu 2044 一隻小蜜蜂...   

簡單的一種離散化

/* 先排序,然後用序號來代替 */#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct node{ int value; int pos; }a[100];bool cmp(node a,node b){ return a.value<b.value;} int main(){ int b[100];

TwoSAT模版(LRJ)

#include<cstdio>#include<cstring>#include<queue>#include<vector>#include<algorithm>using namespace std;const int maxn = 100;struct TwoSAT { int n; vector<int> G[maxn*2]; bool mark[maxn*2]; int S[maxn*2], c;

uva 1086 – The Ministers’ Major Mess(TwoSat)

csdn真是神坑,剛寫的解題竟然被吞了,尼瑪,害我重寫。本題的突破口在每個投票人都要有超過一半的建議被採納。所以對於k<3的,每個建議都得採納,k>=3的,只有一個建議不能採納。都得採納的,我用了一個must數組記錄,然後dfs找出所有開始就定下來的建議的值;只有一個不能採納,即每兩個建議間都至少有一個被採納。最後輸出要判斷“?”,我的方法是對每個建議檢查是否無論它采不採納都有解。開始忘了dfs找所有應該must的建議,2y#include<cstdio>#include

強連通分量SCC模版(LRJ)

#include<cstdio>#include<algorithm>#include<vector>#include<cstring>#include<stack>using namespace std;const int maxn = 1000 + 10;//圖中節點編號從0開始,scc從1開始vector<int> G[maxn];int pre[maxn], lowlink[maxn], sccno[maxn],

Uva 572 – Oil Deposits//深搜,圖

題目很簡單,資料不大,直接深搜。#include<stdio.h>#include<string.h>#define MAXN 105int map[MAXN][MAXN];int n,m;void dfs(int i,int j){ if(!map[i][j]) return; map[i][j]=0; dfs(i+1,j); dfs(i-1,j); dfs(i-1,j-1); dfs(i-1,j+1); dfs(i+1,j-1

uva 11324 – The Largest Clique(縮點 + dp)

文章目錄 Sample inputOutput for sample input Problem B: The Largest CliqueGiven a directed graph G, consider the following transformation. First, create a new graphT(G) to have the same vertex set as G. Create a directed edge

10054 – The Necklace//歐拉迴路

/*判斷有無歐拉迴路 還是老樣子: 先判斷圖是否連通,這道題是無向圖,然後判斷每個點的度,最後列印之*/#include<cstdio>#include<cstring>using namespace std;const int maxn = 1005;int G[maxn][maxn];int degree[maxn];int f[maxn];int n;int find(int x){ if(x != f[x]) { f[x] =

CF 174(div2) D

D. Cow Programtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFarmer John has just given the cows a program to play with! The program contains two integer variables,x andy, and performs the

福州大學四月月賽 01背包 我這樣背不知道那裡寫錯了,請大牛指點

// 題目連結 http://acm.fzu.edu.cn/contest/problem.php?cid=126&sortid=4#include<stdio.h>#include<string.h>struct node{ int x; int y; }a[110];int dp[110][1100];int max(int x,int y){ if(x>y) return x; return y; }int min(int

UVa 10562 – Undraw the Trees//遍曆or遞迴

  這道題初看輸入有點煩,仔細一看就開個二位元組,直接遍曆數組求解就ok了。但是輸出還有括弧,在這裡跪了幾次。然後值得注意的是,節點不一定是字母,頁可以使其他的字元。最後注意邊界就ok啦!下面是代碼:#include<stdio.h>#include<string.h>#define MAXN 210char map[MAXN][MAXN];int n;void dfs(int x,int y){ printf("%c(",map[x][y]); if(x==

CF 190div2 D(貪心)

容易想到需要思考能否把對面全部殺死,如果能,那麼。。。不能,則一定不會去殺防守的。貪心的思路大致有了方向,然後,不能的話,要怎麼做呢?策略是用我這邊最大的比對手最小的。證明如下,假設我手上的任意一張牌x1和最大的牌x2(x1 < x2)和對面的任意一張牌y2和最小的牌(y1 < y2),滿足x2 > y2(否則一個都殺不死),如果y1 < y2 < x1 < x2,則用最大的去殺最小的沒有問題,因為x中任意一張牌都比y大,如果y1 < x1 <

Poj 3685(經典二分)

MatrixTime Limit: 6000MS Memory Limit: 65536KTotal Submissions: 4150 Accepted: 1007DescriptionGiven a N × N matrix A, whose element in the i-th row andj-th columnAij is an number that equals i2 + 100000 ×i +j2 - 100000 × j + i × j, you are to find

CF 131 div2 B

B. Hometasktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFurik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that

Poj 3320(two pointers)

Jessica's Reading ProblemTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5967 Accepted: 1794DescriptionJessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time

uva 11294 – Wedding(TwoSAT)

文章目錄 Sample InputPossible Output for Sample Input Problem E: WeddingUp to thirty couples will attend a wedding feast, at which they will be seated on either side of a long table. The bride and groom sit at one end,

暴力之回溯法入門(持續更新)

刷刷水題,入個門先:百練oj:2754 八皇后西電oj:1010 素數環Poj:1011 Sticks百練oj:2754 八皇后  不過這道題還用存下每個可能解。  下面是代碼:  #include<iostream>#include<cmath>using namespace std;const int maxn = 100;const int N = 8;int A[maxn];int Ans[maxn][10];int n,b,tot;void

Poj 1328(greedy)

Radar InstallationTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 43100 Accepted: 9543DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in

UVa 10382

/* 有一塊草坪,長為l,寬為w, 在它的水平中心線上有n個位置可以安裝噴水裝置, 各個位置上的噴水裝置的覆蓋範圍為以它們自己的半徑ri為圓。求出最少需要的噴水裝置個數。 將他映射到一邊,變成區間覆蓋問題 */#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;#define N 10005 struct

Poj 3104 (二分)

DryingTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 7104 Accepted: 1823DescriptionIt is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided

總頁數: 61357 1 .... 13463 13464 13465 13466 13467 .... 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.