- 货币
- 2017-03-19 17:14:58 @
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<cctype>
#define debug(x) cerr << #x << " = " << x << endl
#define LL long long
#define MAXN 40000010
using namespace std;
inline LL read(){
LL x = 0, f = 1;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x * f;
}
LL f[MAXN];
LL T, n;
map<LL, int> mp;
int tot = 0;
inline LL dfs(LL x){
if(!mp[x]) mp[x] = ++tot;
if(x > x / 2 + x / 3 + x / 4) return f[mp[x]] = x;
if(f[mp[x]]) return f[mp[x]];
return f[mp[x]] = dfs(x / 2) + dfs(x / 3) + dfs(x / 4);
}
int main(){
T = read();
while(T--){
n = read();
cout << dfs(n) << endl;
}
return 0;
}
//救命啊,就是最后一个点