Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- long long int result(int k)
- {
- if(k==1)
- return 0;
- else
- {
- long long int a,ans,x,y;
- double c;
- if(k%5==0)
- a = k/5;
- else
- {
- a = k/5;
- a++;
- }
- ans = 10*result(a) + 2*(k+4-5*a);
- return ans;
- }
- }
- int main()
- {
- long long int t,k,ans;
- cin >> t;
- while(t--)
- {
- cin >> k;
- ans = result(k);
- cout<<ans<<endl;
- }
- }
Add Comment
Please, Sign In to add comment