Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- double h,work,k=1,i,j,nonwork,sum_h,z,countN,countN1;
- while (scanf("%lf %lf",&h,&work)!=EOF)
- {
- k=countN=countN1=1;
- nonwork=sum_h=0;
- if (h==1&&work==1)
- {
- printf("0 1\n");
- }
- else if (h!=0 && work!=0)
- {
- i=(float)pow(h,1/k);
- j=(float)pow(work,1/k);
- while (i!=j+1)
- {
- k=k+1;
- i=(float)pow(h,1/k);
- j=(float)pow(work,1/k);
- }
- for(z=0;z<k;z++)
- {
- nonwork=nonwork+countN;
- countN=countN*j;
- }
- countN=1;
- for(z=0;z<=k;z++)
- {
- sum_h=sum_h+((h/countN1)*countN);
- countN=countN*j;
- countN1=countN1*i;
- }
- printf("%.0lf %.0lf\n",nonwork,sum_h);
- }
- else if (h==0 && work==0)
- break;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment