首页 > 其他 > 详细

(组合数学)不定方程的解+猜测——cf997B

时间:2019-06-30 00:42:44      阅读:126      评论:0      收藏:0      [点我收藏+]

首先要求出三种等价情况

5×1+1×50=1×5+5×105×1+1×50=1×5+5×10
9×5=5×1+4×10
8×5+1×50=9×10
 
那么可以求出三种关于x5,x10的不可行条件
x5 ≥ 1 且 x10 ≥ 5
x≥ 9
x10 ≥ 9
那么只要依次枚举这x5,x10的可能的取值,用不定方程的解数量累计即可
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while (cin >> n)
    {
        long long ans = 0;
        for (int i = 0; i <= 8 && i <= n; i++)
        {
            for (int j = 0; j <= (i == 0 ? 8 : 4) && i + j <= n; j++)
            {
                ans += n + 1 - i - j;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

 

 

(组合数学)不定方程的解+猜测——cf997B

原文:https://www.cnblogs.com/zsben991126/p/11108284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!