HDU1017Java

来源:互联网 发布:ai软件什么时候上市 编辑:程序博客网 时间:2024/06/05 18:33
public class Main {public static void main(String[] args) {Scanner cin = new Scanner(System.in);int T = cin.nextInt();while(T-- > 0){int num = 0;int n = cin.nextInt();int m = cin.nextInt();while(!(m==0 && n==0)){int ans = 0;for (int a = 1; a < n; a++) {for (int b = a+1; b < n; b++) {if((a*a + b*b + m)%(a*b)==0){ans++;}}}num++;System.out.println("Case "+num+": "+ans);n = cin.nextInt();m = cin.nextInt();}if(T>0) System.out.println();}}}
这道题我提交很多次都没有过原因是我把题的数据理解错了  它是一组数据可以输出若干个答案 只有当两个都等于0的时候才结束而且当第一组数据结束了需要换行最后一组数据不需要换行。需要细心  本体的大概意思就是题中的那个公式 没有什么特别之处。