码迷,mamicode.com
首页 > 其他好文 > 详细

HDU2566 统计硬币

时间:2018-10-04 11:00:46      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:scan   printf   hdu2566   枚举   amp   stream   ==   void   str   

思路:暴力枚举。

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int cnt = 0 ;
        int n,m;
        scanf("%d%d",&n,&m);
        for(int i = 0; i <= n; i++)
            for(int j = 0; j <= n; j++)
                for(int k = 0; k <= n; k++)
                    if(i+2*j+5*k==m&&i+j+k==n)
                        cnt++;           
        printf("%d\n",cnt);
    }
    return 0; 
}

 

HDU2566 统计硬币

标签:scan   printf   hdu2566   枚举   amp   stream   ==   void   str   

原文地址:https://www.cnblogs.com/AC-AC/p/9739633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!