tarjan演算法的實現

自己將tarjan演算法實現了一遍,深入理解了一遍,感覺有所收穫~~  #include<iostream>using namespace std;int time=1,low[1000],dfn[1000];int stack[1000],top=0;bool instack[1000]={false};struct LIST{int v;LIST *next;};LIST *head[1000]={NULL};int min(int a,int

poj1306解題報告

題目大意:求C(m)(n),輸出結果的二進位不超過32位。。思路:先將1~100的素數打表,然後把每個分子分母分解質因數,記錄下分子因數分解的情況,分子質因數表加到一起,分母的表加到一起,最後把分子的質因數表減去分母的質因數表,然後結果就好球了。。#include<iostream>#include<cmath>using namespace std;int prime[50];void find(){prime[0]=2;int

poj1159解題報告

題目大意:給定一個字串,讓你在這個串中加入最少的字元,使其成為迴文串,(迴文串就是正著讀和反著讀一樣的串)比如:"Ab3bd"加入最少加入兩個字元才能成為迴文串"dAb3bAd"或者 "Adb3bdA"。。。。求最少添多少個字元。。。 思路:假設長度為len的字串存在str[ ]裡,初始left=0,right=len-1,如果str[left]不等於str[right]那麼則有find(letf,right)=min(find(left,rght-1),find(left+1,right)),

poj2533解題報告

題意:求一個序列中最長上升子序列Sample Input71 7 3 5 9 4 8Sample Output4思路:以第i位元素開始的最長上升子序列長度等於1加上i+1~n中的某個j位的最長上升子序列(a[i]<a[j]),然後遞迴求解#include<iostream>using namespace std;int n,a[1010],maxl[1010];void find(int i){int j,flag=0;for(j=i+1;j<=n;j++)if(a[j]

poj2245解題報告

題目大意:給定一個遞增的序列,輸出在這個序列中的6個元素的遞增全排列。。。  #include<iostream>using namespace std;int num[20],n;void find(int i,int finded,int shows[]){int

多校聯合賽(一)1009 I-number

好長時間沒寫部落格了,一想起“水可三日不飲,飯可七日不食,而程不可一日不編”,還是回顧一下最近的內容,下午打了場多校說下這道A下的第一題。Problem DescriptionThe I-number of x is defined to be an integer y, which satisfied the the conditions below:1. y>x;2. the sum of each digit of y(under base 10) is the

矩形面積並

#include <iostream>#include <vector>#include <algorithm>#include<cstdio>using namespace std;typedef double Type;#define ll double#define maxn 200200// 垂直線段struct VLine { Type x; Type y1, y2; int val; VLine() {}

多校聯合賽(一) 1008 Park Visit

題目是這樣的Problem DescriptionClaire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the park are connected by exactly (N-1) undirected paths, and Claire is too tired to

HDU2602 Bone Collector (簡單01背包問題)

Bone CollectorTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21250    Accepted Submission(s): 8521Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone

HDU上一道最小產生樹模板題的練習

StatisticsEddy's picture Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 7   Accepted Submission(s) : 4Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionEddy begins to

poj1426解題報告

DescriptionGiven a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no

poj2498解題報告

StuPIdTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 5111 Accepted: 2631DescriptionBackground At DUT, the Dreamland University of Technology, all students have personal id, numbers with six or seven digits. But they're not just any

CCNU第五周賽前練習:將一個數分解成質因子相乘的形式

K -Number theory-2Time Limit:1000MS    Memory Limit:32768KB    64bit IO Format:%I64d & %I64uSubmitStatusDescriptionEddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided

哈工程OJ 1253 馬和象的故事 BFS

馬和象的故事TimeLimit: 1 Second   MemoryLimit: 32 Megabyte Totalsubmit: 215   Accepted: 46   Special Judge

經典面試題 — 讓CPU佔用率聽你指揮

在《編程之美》上有這麼一道題,題目是:編程讓CPU的佔用率呈正弦曲線變化。 初看這題基本沒什麼思路,後來瞭解到CPU佔用率的計算公式就找到突破口了。 CPU佔用率計算公式:CPU佔用率 = 已耗用時間/總時間 x 100%  有了上面的公式,只需要讓一個時間片內啟動並執行時間占該時間片的比例呈正弦變化即可。  //正弦曲線的 double time = 0.0 ; double runtime ; int c; while(1) {  runtime = 100 + 100 *

poj2381解題報告

Random GapTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 3538 Accepted: 871DescriptionThe pseudo-random number genegators (or RNGs for short) are widely used in statistical calculations. One of the simplest and ubiquitious is the linear

11205 – The broken pedometer

語言:C++描述:這道題其實一開始自己就是錯誤思維,題目就是通過最少的二進位位表示所有的數,也就是說存在自由組合的問題,不過存在這樣的問題:如果一列位元被刪去後,可以使列數減一來表示了所有的數了,但是有可能列數只會減一,輸出的結果就是列數-1了,也就是說其他還有可能的情況都被封鎖了。所以,原本的方法出現了錯誤,雖然測試資料過了,但是uva測試資料過不了,然後不得不根據劉汝佳書上的位向量法改寫了一點才AC的#include <iostream>#include

POJ1523解題報告 求點割集

SPFTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2082 Accepted: 932DescriptionConsider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis, a failure

俄羅斯方塊機器人2

以前寫的俄羅斯方塊機器人程式只找當前圖形的最佳擺放位置,而沒有考慮當前圖形對下一個圖形擺放的影響,這回我在原來的基礎上加入了這個功能,效果比較明顯,在一般情況下(就是不是特別雖的情況下)可以消超過100行,但隨機產生的圖形特別難擺我也就沒招了。。  PS:俄羅斯方塊我玩的不好,寫出的程式也就是把我玩俄羅斯方塊的技巧實現一下,我的技巧是,盡量不留空,盡量往低放,盡量消行。如果我和這個程式對戰,我肯定玩不過它。。。 編寫環境:VC++

一道面試題,求1~n中1出現的次數

今天下午創業教育課上無聊,想起來一道微軟的面試題,即求1~n中1出現的次數 例如n=11 則1一共出現4次:1 10 11 這個問題我仔細思考了一陣,推出了一個很快的解法(複雜度lg(N))...寫在BLOG上儲存思路: 首先確定個位1的個數,再統計十位1的個數,.....統計最高位1的個數全部累加即為所求.設n=497 則過程如下: 個位1數:       由於497中的"49"是由於個位進位得到的,不難想出個位一共進了49位,每次進位個位出現一個1,因此個位1的個數等於490/10+剩下'7

總頁數: 61357 1 .... 8687 8688 8689 8690 8691 .... 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.