Guest User

Untitled

a guest
Feb 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. double h,work,k=1,i,j,nonwork,sum_h,z,countN,countN1;
  6.  
  7. while (scanf("%lf %lf",&h,&work)!=EOF)
  8. {
  9. k=countN=countN1=1;
  10. nonwork=sum_h=0;
  11. if (h==1&&work==1)
  12. {
  13. printf("0 1\n");
  14. }
  15. else if (h!=0 && work!=0)
  16. {
  17. i=(float)pow(h,1/k);
  18. j=(float)pow(work,1/k);
  19. while (i!=j+1)
  20. {
  21. k=k+1;
  22. i=(float)pow(h,1/k);
  23. j=(float)pow(work,1/k);
  24. }
  25. for(z=0;z<k;z++)
  26. {
  27. nonwork=nonwork+countN;
  28. countN=countN*j;
  29. }
  30. countN=1;
  31. for(z=0;z<=k;z++)
  32. {
  33. sum_h=sum_h+((h/countN1)*countN);
  34. countN=countN*j;
  35. countN1=countN1*i;
  36. }
  37. printf("%.0lf %.0lf\n",nonwork,sum_h);
  38. }
  39. else if (h==0 && work==0)
  40. break;
  41. }
  42. return 0;
  43. }
Add Comment
Please, Sign In to add comment