首页 > 代码库 > Codeforces Round #273 (Div. 2)

Codeforces Round #273 (Div. 2)

A题

1 s = sum(map(int, raw_input().split()))2 print s / 5 if s % 5 == 0 and s / 5 else -1

B题

1 n, m = map(int, raw_input().split())2 div, lft = n / m, n % m;3 mi = (div + 1) * (div) / 2 * lft + (div) * (div - 1) / 2 * (m - lft);4 print mi, (n - m + 1) * (n - m) / 2

C题

1 a = map(int, raw_input().split())2 a.sort()3 print a[0] + a[1] if (a[0] + a[1]) * 2 <= a[2] else sum(a) / 3

D题

 1 /************************************************************************* 2     > File Name: D.cpp 3     > Author: Stomach_ache 4     > Mail: sudaweitong@gmail.com 5     > Created Time: 2014年10月17日 星期五 21时39分21秒 6     > Propose:  7  ************************************************************************/ 8 #include <cmath> 9 #include <string>10 #include <cstdio>11 #include <fstream>12 #include <cstring>13 #include <iostream>14 #include <algorithm>15 using namespace std;16 /*Let‘s fight!!!*/17 18 const int MOD = 1e9 + 7;19 const int MAX_N = 200050;20 int dp[MAX_N];21 22 int main(void) {23       ios_base::sync_with_stdio(false);24     int r, g;25     cin >> r >> g;26     int h = 1;27     while (h * (h + 1) / 2 <= r + g) h++;28     h--;29 30     memset(dp, 0, sizeof(dp));31     dp[0] = 1;32     for (int i = 1; i <= h; i++) {33           for (int j = r; j >= i; j--) {34               dp[j] = (dp[j] + dp[j - i]) % MOD;35         }36     }37     h = h * (h + 1) / 2;38     int res = 0;39     for (int i = 0; i <= r; i++) if (i + g >= h) res = (res + dp[i]) % MOD;40     cout << res << endl;41 42     return 0;43 }

 

Codeforces Round #273 (Div. 2)