跳到主要內容

發表文章

目前顯示的是 2015的文章

Codeforces Round #325 (Div. 2)

A. Alena's Schedule   每次有1就加1,沒有1的話就看看如果有兩個0就不加1  要注意的點是一開始的0不用理他 B. Laurenty and Shop 把路徑全部加起來排序取最小的兩個加起來就可以了 C. Gennady the Dentist 這題目寫得不太好 沒有說孩子們哭完才移動位置,還是移動完才繼續哭 不過仔細一看才知道外面有note寫說哭是比移動位置早的 所以在牙醫室裡面哭的孩子在外面傳遞的聲量是以當時的狀態去傳遞 接下來就很簡單了

Codeforces Round #326 (Div. 2)

Codeforces Round #326 (Div. 2) A. Duff and Meat 水題就不多說了 一直記錄最小值就可以了 __author__ = 'GCA' # Date: 2015/10/18 n = int(input()) minp = 200 total = 0 for i in range(n): ai, pi = list(map(int, input().split())) if pi < minp: minp = pi total += minp * ai print(total) B. Duff in Love 只要用快速mod的方式去找出每個質因數,而如果答案沒辦法整除這個質因數就把這個質因數乘起來 __author__ = 'GCA' # Date: 2015/10/19 n = int(input()) a = n ** 0.5 + 1 d = 2 A = 1 while d <= a: if n % d == 0: n //= d if A % d != 0: A *= d else: d += 1 if n > 1: A *= n print(A) C. Duff and Weight Lifting 只要有兩個以上的A數字 就可以mod 2變成只有1個or 0個 只剩1個的話代表無法合併 為一個step 而map(A+1)可以加上A / 2的數量 並且一直往大的數字推 __author__ = 'GCA' // Created by GCA on 2015/10/19 #include using namespace std; const int maxn = 1000105; int a[maxn]; int n; int main() { memset(a, 0, sizeof(a)); scanf("%d", &n); for (int i = 0; i < n; i++) { int t;