heisenberg0820

Untitled

Jun 3rd, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. long long int result(int k)
  7. {
  8. if(k==1)
  9. return 0;
  10. else
  11. {
  12. long long int a,ans,x,y;
  13. double c;
  14. if(k%5==0)
  15. a = k/5;
  16. else
  17. {
  18. a = k/5;
  19. a++;
  20. }
  21. ans = 10*result(a) + 2*(k+4-5*a);
  22. return ans;
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. long long int t,k,ans;
  29. cin >> t;
  30. while(t--)
  31. {
  32. cin >> k;
  33. ans = result(k);
  34. cout<<ans<<endl;
  35. }
  36. }
Add Comment
Please, Sign In to add comment