HDU1017 - A Mathematical Curiosity (枚举)

来源:互联网 发布:代理服务器软件下载 编辑:程序博客网 时间:2024/06/03 21:17

题目链接

  • 思路
  • 代码

思路

看懂题意,枚举 a,b就行了。注意下题目描述的格式。

代码

#include <cstdio>using namespace std;int main(){    int t, n, m;    bool flag = true;    scanf("%d", &t);    while(t--)    {        if(flag) flag = false;        else printf("\n");        int tt = 0;        while(scanf("%d%d", &n, &m) && n)        {            int ans = 0;            for(int i=1; i<n; i++)            {                for(int j=i+1; j<n; j++)                    if((i*i+j*j+m)%(i*j)==0) ans++;            }            printf("Case %d: %d\n", ++tt, ans);        }    }    return 0;}
0 0
原创粉丝点击