We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>usingnamespacestd;#define int long longvector<int>maxima={1,2,3,6,7,9,18,19,25,27,54,55,73,97,129,171,231,235,313,327,649,654,655,667,703,871,1161,2223,2322,2323,2463,2919,3711,6171,10971,13255,17647,17673,23529,26623,34239,35497,35655,52527,77031,106239,142587,156159,216367,230631,410011,511935,626331,837799,1117065,1126015,1501353,1564063,1723519,2298025,3064033,3542887,3732423};voidtest_case(){intn;cin>>n;autoit=upper_bound(maxima.begin(),maxima.end(),n);it--;cout<<*it<<"\n";return;}int32_tmain(){ios_base::sync_with_stdio(0);cin.tie(0);int32_tt;cin>>t;while(t--)test_case();return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #14: Longest Collatz sequence
You are viewing a single comment's thread. Return to all comments →
is doing like this is fine?