hdu 4565 So Easy!

Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn.  You, a top coder, say: So easy!  Input  There are several test cases, each test case in one line contains four positive integers: a, b, n, m.

hdu 4467 Graph

P. T. Tigris is a student currently studying graph theory. One day, when he was studying hard, GS appeared around the corner shyly and came up with a problem:Given a graph with n nodes and m undirected weighted edges, every node having one of two

dp hdu-4433 locker

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4433題目大意:給兩個長度相等的數字串s1,s2。每次操作可以把連續的最多三位都+1或-1,如果超過9則變成0,如果小於0則變成9.問從s1到s2最少的步數。解題思路:每一位移動正確最多5位,如果一位一位的移動最多需要1000*5=5000 。長度有1000太大,不能直接用BFS。因為每次改變最多隻影響3位,前面的i-3位不改變,所以可以設dp[i][j][k]表示處理到了第i位,且最後兩位分別為j,

hdu 4268 Alice and Bob

Alice and Bob's game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively. Alice wants to use his cards to cover Bob's. The card A can cover the card B if the height of A is not

類比+二分 poj-1019-Number Sequence

題目連結:http://poj.org/problem?id=1019題目大意:Sk表示123...k把S1S2S3...Sk排成一行 比如:112123123412345123456....求第i個數字是多少。解題思路:如果Sk表示123...k所佔的位元,顯然Sk=Sk-1+Cal(k)。Cal(k)表示k的位元。先打表預先處理sum[i]=S1+S2+..+Si;然後在sum[i]中尋找第n個屬於哪一個Sk. 在同一個Sk中,一位有1~9 9個,2位有10~99 90個   3位有100~

floyd+動態規劃 hdu-4571-Travel in time

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4571題目大意:有n個景點,每個點都有個遊玩時間ci,遊玩後得到的滿意度si。給一個起點s和終點e,兩個景點間有條無向邊,權值為時間。從起點出發,在給定時間限制下,到達終點,問能獲得的最大的滿意值,只有遊玩了景點才能獲得該景點的滿意值,並且上個遊玩景點的滿意度必須大於後一個遊玩的景點滿意度。解題思路:圖上的dp.見到圖論就暈啊啊啊。先求出不遊玩時,任意兩點的到達時間,用floyd求。dp[i][j]表

dp+計數 poj-1037-A decorative fence

題目連結:http://poj.org/problem?id=1037題目大意:給一個n,求出1~n組成波浪形按字典序的第m種序列。解題思路:經典dp+計數。之前做個一道,只需求所有的種數,但現在要求第m種,所以要考慮計數,所以不能僅以長度和上升下降兩維來處理,還需增加一維表示以某個開始。dp[i][j][0]表示長度為i,以第j長的開始,且前兩個為下降的種數。只和相對長度有關,故此處j指第j長的。1表示上升。重點是計數,先找從小到大找第1個,如果m<=該數開始的種數時,說明第一位一定是該

dp hdu-4570-Multi-bit Trie

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4570題目意思:轉化題意,就是給n個數,求一個劃分使得每一段的第一個數乘以2的該段個數次方的和最小。每一段的個數不超過20。解題思路:dp[i]表示i個數時滿足題目要求的劃分的最小總和。dp[i]=Min(dp[i],sa[i-j+1]*bi[j]+dp[i-j]);代碼:#include<iostream>#include<cmath>#include<cstdio&g

數學題-hdu-4569-Special equations

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4569題目意思:給一個不超過四次的一元多項式,求一個x使得該多項式的值mod給定質數p的平方為0.解題思路:設給定的多項式為f(x)=a4*x^4+a3*x^3+a2*x^2+a1*x+a0顯然f(x+p^2)=f(x)mod(p^2).故只需討論0~p^2範圍內(其他數如果滿足,一定可以轉化到該範圍內)是否存在滿足題意的。如果直接o(p^2)的話肯定會逾時,所以需要剪枝。因為p為質數,並且f(x+p

dp poj 1080 Human Gene Functions

題目連結:http://poj.org/problem?id=1080題目大意:給兩個由A、C、T、G四個字元組成的字串,可以在兩串中加入-,使得兩串長度相等。每兩個字元匹配時都有個值,求怎樣安排使得總的值最大,兩個-不能匹配。解題思路:這題轉化一下就是一個裸的最長公用子串問題,只不過要求匹配時間長度度一樣。dp[i][j]表示第一串的第前i個字元和第二串的前j個字元匹配時,能達到的最大值。初始化時注意dp[0][j]和dp[j][0]不能為零,為相應字元與-匹配時的總和。代碼:#include

最短路+狀態壓縮dp(旅行商問題)hdu-4568-Hunter

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4568題目大意:給一個矩陣 n*m (n

hdu 4276 The Ghost Blows Light

The Ghost Blows LightTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1606    Accepted Submission(s): 490Problem DescriptionMy name is Hu Bayi, robing an ancient tomb in Tibet. The tomb consists

poj 1655 Balancing Act

Balancing ActTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7412 Accepted: 2994DescriptionConsider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more

枚舉+搜尋 hdu-4431-Mahjong

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=4431題目大意:給一副牌,求出所有能糊的牌。解題思路:枚舉每一張牌,看能不能糊。因為一共只有14張牌,每次依據將,去掉三張牌,判斷最後兩張牌是否一樣。七對和十三么單獨考慮,注意:1、1p 1p 1s 9s 1m 9m 1c 2c 3c 4c 5c 6c 7c 這樣的也可以糊9p。2、七對時,要為不同的牌,1s 1s 1s 1s

hdu 3516 Tree Construction

Tree ConstructionTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 684    Accepted Submission(s): 364Problem DescriptionConsider a two-dimensional space with a set of points (xi, yi) that satisfy

(poj 1475) Pushing Boxes

Imagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move north, south, east or west one cell at a step. These moves are called walks. One of the empty cells contains a box

hdu 1026 Ignatius and the Princess I

Ignatius and the Princess ITime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9433    Accepted Submission(s): 2784Special JudgeProblem DescriptionThe Princess has been abducted by the BEelzebub

hdu 4487 Maximum Random Walk

Consider the classic random walk: at each step, you have a 1/2 chance of taking a step to the left and a 1/2 chance of taking a step to the right. Your expected position after a period of time is zero; that is, the average over many such random

QtRegex的貪婪模式

使用了2個Regex庫,分別是QRegExp、pcre和pcre++。Regex的寫法一般都是通用的,但對於貪婪匹配,不同的正則庫有些不同。在pcre中,非貪婪模式是由'?'來指定的,但在QRegExp中,存在'?',為不合法的Regex,在QRegExp中,要使用setMinimal函數來指定貪婪演算法。setMinimal函數的意思是設定最小匹配,也就是非貪婪。1.例子:從html代碼中抓取隱藏欄位內容:<form method="post" name=""

hdu 4491 Windmill Animation

A windmill animation works as follows:A two-dimensional set of points, no three of which lie on a line is chosen. Then one of the points is chosen (as the first pivot) and a line is drawn through the chosen point at some initial angle. The animation

總頁數: 61357 1 .... 19624 19625 19626 19627 19628 .... 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.