原创 F - Prime Path --BFS廣搜
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all hav
原创 Shuffle'm Up ----bfs
A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by star
原创 Prime Ring Problem
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the
原创 篩選法求素數表----埃拉託斯特尼篩法
適用於題目的數據規模較大,常規地逐個判斷素數的方法行不通,可以使用篩選法進行預處理,將所有素數一次性求出並存入數組中。分析:從2開始,將每個素數的各個倍數,標記成合數。一個素數的各個倍數,是一個差爲此素數本身的等差數列。實現:建立一個bo
原创 ACM算法設計---BFS、DFS
https://wenku.baidu.com/view/97c9220452ea551810a687e4.html
原创 Wireless Network
Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless
原创 A - 棋盤問題 搜索
在一個給定形狀的棋盤(形狀可能是不規則的)上面擺放棋子,棋子沒有區別。要求擺放時任意的兩個棋子不能放在棋盤中的同一行或者同一列,請編程求解對於給定形狀和大小的棋盤,擺放k個棋子的所有可行的擺放方案C。Input輸入含有多組測試數據。 每組
原创 Prime Ring Problem
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the
原创 u Calculate e
A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate a
原创 A + B Problem II
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input
原创 大明A+B
話說,經過了漫長的一個多月,小明已經成長了許多,所以他改了一個名字叫“大明”。 這時他已經不是那個只會做100以內加法的那個“小明”了,現在他甚至會任意長度的正小數的加法。 現在,給你兩個正的小數A和B,你的任務是代表大明計算出A+
原创 Hat's Fibonacci
A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being b
原创 Children’s Queue
There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a
原创 N!
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, process to the end of file
原创 天梯 L1-027. 出租
下面是新浪微博上曾經很火的一張圖: 一時間網上一片求救聲,急問這個怎麼破。其實這段代碼很簡單,index數組就是arr數組的下標,index[0]=2 對應 arr[2]=1,index[1]=0 對應 arr[0]=8,index