首页 > 代码库 > codeforces #Round273(div2) D

codeforces #Round273(div2) 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 #Round273(div2) D