題目大意:就是如果P不是素數,能否滿足ap =a (modp)思路:直接素數判斷+快速冪模數即可,我開始用的是普通素數判斷,後來用了miller_rabin改進版的的素數測試,權當模板吧 AC program:(普通素數判斷+快速冪)#include<iostream>#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using
題目大意:兔子和烏龜賽跑,烏龜可以騎電動車,並且在路途中建立充電站,每次充電消耗t時間,每次充電後可以騎c距離,問比賽結果思路:dp不能只是看i-1充電站的狀態,因為有可能是在之前(0-i-1)的充電站直接充了電就直達當前所在網站的.所以對於每個充電站,要重新掃一遍.dp[i]表示到達i站所用的時間最少是多少.dp[i]一定是由前面的某一個網站充電後到達的最小值.但不一定是i-1這個網站.在0~i-1中的網站到達i網站都可能有兩種狀態:(1)騎電動車+蹬電動車(2)騎電動車 AC
Cheapest PalindromeTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 4648 Accepted: 2263DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an
Cow ExhibitionTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7795 Accepted: 2852Description"Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to the public
Space ElevatorTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7192 Accepted: 3370DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <=
Milking TimeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3603 Accepted: 1530DescriptionBessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,00
I Love This GameTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3740 Accepted Submission(s): 1286Problem DescriptionDo you like playing basketball ? If you are , you may know the NBA Skills
Bridging signalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 9454 Accepted: 5177Description'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up
CoinsTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 25745 Accepted: 8717DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some
資料量很大,尋找的時候很耗時間,就想到隊長所說的二分演算法了,又碼了一遍,加深一下印象。題目連結就是注意儲存資料時用long long 來儲存,要不會爆掉。#include<stdio.h>#include<string.h>#include<iostream>#include<math.h>using namespace std;const int MAX=2000000000;const int maxn=200000;long long
Wooden SticksTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 16517 Accepted: 6868DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking
A. Cows and Primitive Rootstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe cows have just learned what a primitive root is! Given a prime p, a primitive root is an
Dollar DayzTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2912 Accepted: 1158DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling
B. Cows and Poker Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or
Ant CountingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1954 Accepted: 822DescriptionBessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were