hdu 1695(超时)

 1 #include <iostream>
2 using namespace std;
3 #include <stdio.h>
4
5 int gcd(int h,int l){
6 if(l==0) return h;
7 else return gcd(l,h%l);
8 }
9
10 int main(){
11 int n,m,k,i,j,l,p,t,x,y,ca=0;
12 __int64 sun;
13 scanf("%d",&t);
14 while(t--){
15 sun=0;
16 ca++;
17 scanf("%d %d %d %d %d",&i,&n,&j,&m,&p);
18 if(p==0) { printf("Case %d: 0\n",ca); continue; }
19 n/=p;
20 m/=p;
21 x=n>m? n:m; //
22 y=n>m? m:n; //
23
24 for(i=1;i<=y;i++)
25 for(j=i;j<=x;j++)
26 if(gcd(j,i)==1) sun++;
27
28 printf("Case %d: %I64d\n",ca,sun);
29 }
30 return 0;
31 }

  

posted @ 2011-09-17 10:32  shark_cf  阅读(147)  评论(0)    收藏  举报