Time of Update: 2018-12-03
這是一道非常經典也是很好玩的一道題目,而自己需要做到的就是,將以前的做法完全的顛覆,自己通過現在學到的知識去改變做法,這樣才能體現出,自己比別人的思想進步.呵呵.看代碼:#include <stdio.h>#include <string.h>#include <iostream>#include <string>#include <algorithm>#define F(a) a*a*ausing namespace
Time of Update: 2018-12-03
這個題目還是挺有意思的就是,痛點就是,輸出的問題,,說說步驟,首先應該找到公用序列的i,j座標,以及本身的值,然後就是遍曆str1,如果遇到不是公用序列的i就輸出,while迴圈;同樣的是遍曆str2,如果沒有遇到公用序列中的j就一直輸出,while迴圈;這些都輸出都結束之後,就可以輸出公用序列了.現在貼出My Code,,今天下午一直狀態不佳,,,誒,,主要是天氣太熱了點,,煩的要命.代碼:#include <stdio.h>#include
Time of Update: 2018-12-03
其實只要弄明白拓撲排序的原理,自己還是很容易實現出自己的拓撲排序的,但需要注意的幾點,分別有:要注意重邊,雖然這道題目,你注意不注意都可以過,然後就是一定要注意注意注意加註意的一點是:找到一個就立馬退出迴圈!要不然 容易出現這種情況5 6 5 1,你找到了5 然後你不退出的話就會直接繼續找6,但其實應該是輸出1的..誒...所以,以後還是要小心點的,當然多做定題目,多積累點經驗還是有必要的.貼出代碼:#include <stdio.h>#include
Time of Update: 2018-12-03
主要用到的還是gcd函數,很簡單的一道題目,大家看看代碼:#include <stdio.h>#include <string.h>#include <iostream>#include <string>#include <algorithm>using namespace std;int gcd (int a, int b){return a % b == 0 ? b : gcd (b, a % b); }//
Time of Update: 2018-12-03
很簡單的一道題目,就主要是吧已經修建成功的賦成map[i][j]就行了.貼出代碼:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#define inf 0x3fffffffint N,M;// N represents the number of points,and M stands for the number of that has been
Time of Update: 2018-12-03
這道題目是比較簡單的,我主要是不知道有沒有什麼進階一點的質因數分解的演算法,我發現也沒有什麼更進階的演算法,就是我自己想的那些演算法,嘿嘿.一會就實現了他,呵呵.貼出代碼:#include <stdio.h>#include <string.h>#include <iostream>#include <string>#include <algorithm>using namespace std;int Solve (int x,
Time of Update: 2018-12-03
其實我們如果以前沒有遇到過這種題目,然後自己再猛然遇到種數學技巧性的題目的時候是最無辜的....用以前的辦法解決逾時,而新的自己又不會...所以解決這種問題就是多做題目,多總結相似點.現在貼出代碼,這代碼當然也是參考別人的,嘿嘿#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int p[500005];int main(){int T;for(int
Time of Update: 2018-12-03
以前一直都不敢想這個問題,總覺得,這個問題應該是有什麼高深的演算法,現在上網查了查,也沒有發現什麼高深的演算法,也就是這樣寫的.自己編了一次以後就有信心咯,呵呵.看看My Code:/*質因數分解的問題,主要是進行如下步驟,第一步就是將求出所有的素數表,存入數組,然後再進行素數分解.注意:首先輸入你要分解的數位個數,然後再輸入你要分解的數字; */#include <stdio.h>#include <string.h>#include
Time of Update: 2018-12-03
這道題目是一道簡單的DFS,只需要用鄰接表構出邊之後,進行DFS,一次DFS之後自加1,就可以貼出代碼:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int N,M;//N represents the number of points,and M stands for the number of edges;int
Time of Update: 2018-12-03
我覺得這道題目用到的思想就是,一個atoi轉換函式,還有就是解決問題的遞迴思想,解決了前一個問題,後面的就可以遞迴調用這種解決方案.還有就是類比解決方案的能力,以後的題目,你不可能一看就知道怎麼做的,也不可能確定自己的方法就是最簡單的方法,但是你可以用笨笨的方法解決,這也是一種能力,就是實現自己思想,將自己的思想轉換成代碼的能力!#include <stdio.h>#include <string.h>#include <stdlib.h>#include &
Time of Update: 2018-12-03
其實就是讓你求出來,所輸入的字串中的大寫字母,然後輸出,,自己的代碼就不看了,醜死了,看標稱:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <iostream>#include <ctype.h>#include <string>using namespace std;int
Time of Update: 2018-12-03
這道題目我真的有點淚奔了!寫了整整一下午才A掉,這是一道比較考察綜合知識的題目,要求你對DFS,要求你對模型的建立,要求你對圖的掌握要非常熟練。如果是不熟練的話,你是寫不出來的。這個題目的意思是,給你N個結點,代表著用戶端和服務端,用戶端僅為這個無根樹的葉結點時,其餘的就是服務端了,但是有一個是發射訊號的最終用戶端,就要求著,如果有用戶端距離服務端太遠(距離超過所要求的K)的話,就無法正確的接受到訊號了,所以就要重新再建立一個服務端了。題目要求求出需要建立的最少的服務端。做題的步驟應該是這樣的:
Time of Update: 2018-12-03
運算子的重載是比較重要的內容,,#include <stdio.h>#include <iostream>#include <algorithm>using namespace std;struct node{int a;int b;bool operator< (const node t){if(this->a!=t.a)return a>t.a;elsereturn this->b>t.b;}bool operator== (
Time of Update: 2018-12-03
最基本的組合數學的題目我卻墨跡了半天,十分的沒有效率。不知道怎麼辦了都,一定要提高效率,要不然真的不行。放蘋果Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 23439 Accepted: 14873Description把M個同樣的蘋果放在N個同樣的盤子裡,允許有的盤子空著不放,問共有多少種不同的分法?(用K表示)5,1,1和1,5,1 是同一種分法。Input第一行是測試資料的數目t(0 <= t <= 20)。
Time of Update: 2018-12-03
fill()演算法確實好用,雖然不知道,時間複雜度是多少,但是用起來好方便的,,我覺得時間複雜度應該不高吧? 上百度查了一下也查不出來.還有那個遍曆演算法,也是很省事的呼呼.,..而且還可以加函數演算法op();確實神奇...#include <stdio.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <algorithm>#include
Time of Update: 2018-12-03
一道水題,我隨便翻翻到的,想想自己說不定和這道題目有緣呢.呵呵,就做這玩吧呵呵.#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int a[1005];int gcd(int a,int b){return a%b==0?b:gcd(b,a%b);}int main(){int N;while(scanf("%d",&N)!=EOF){for(
Time of Update: 2018-12-03
這道題目還是蠻好玩的,運用到了素數的篩選法,對於自己的複習還是不錯的,自己有很多細小錯誤的方面還是沒有記住,看代碼:#include <stdio.h>#include <string.h>#include <math.h>#include <iostream>#include <string>#include <algorithm>#define Maxn 1000011using namespace std;bool
Time of Update: 2018-12-03
其實一開始就有思路的,但是,我一看,演算法是兩重迴圈..雖然不逾時,覺得還是不好,覺得DP應該不會這樣吧...別了我很長時間,最後還是想去試試吧,,試了一試,還真是這麼算..暈了.貼出代碼:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int a[1005];int dp[1005];int max(int a,int b){return a>
Time of Update: 2018-12-03
其實老早我就寫過這個蛇形矩陣的題目了.所以這次還算是比較輕鬆的寫出來了,只不過是可惜的是自己還是寫了比較長的時間而且也改錯改了一些時間.嘿嘿.我覺得這道題目就是一道類比的題目.大家給看看咯.嘿嘿.#include <stdio.h>#include <string.h>#include <iostream>#include <string>#include <algorithm>using namespace std;int
Time of Update: 2018-12-03
今天下午一點狀態也沒在,,這個也改不過來了先貼上別人的代碼和自己的錯誤碼等有空自己再改吧#include <stdio.h>#include <stdlib.h>struct No{int w;int s;int num;}a[1005];int cmp(const void *c,const void *d){return *(int *)c-*(int *)d;}int main (){int n=0,i,j,k,max;int