Codeforces Round #326 (Div. 2)
A. Duff and Meat
There's no need to say much about this easy problem, just keep track of the minimum value.
\_\_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 Just use the fast modulo method to find each prime factor, and if the answer cannot be divided by this prime factor, multiply it.
\_\_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 If there are more than two numbers A, it can be mod 2 to become either 1 or 0. If there is only one left, it means that it cannot be merged and becomes one step. And map(A+1) can add the quantity of A / 2, and keep pushing to the larger number.
__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;
scanf("%d", &t);
a[t]++;
}
int ans=0;
for (int i = 0; i < maxn; i++) {
ans += a[i]%2;
a[i+1]+=a[i]/2;
}
printf("%d\n",ans);
}