?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
82536959 |
Contestant: gurpreet_ait |
1362C - 20 | C++14 (GCC 6-32) | Wrong answer on test 8 | 46 ms | 260 KB | 2020-06-04 18:57:08 | 2020-06-04 20:37:46 |
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t;cin>>t; ll precal[60]; precal[0]=1; for(int i=1;i<60;i++) precal[i]=2*precal[i-1]+1; while(t--) { ll n,sum=0;cin>>n; while(n>0) { ll k=log2(n); //cout<<k<<"\n"; sum+=precal[k]; ll cal=pow(2,k); n-=cal; } cout<<sum<<"\n"; } }
?
?
?
?