#include #include int main(){ long long i,k; scanf("%lld",&k); i=0; //tim so i lon nhat thoa man tong 2^1+2^2+...+2^i<= k <=> 2^(i+1)-2<=k while((pow(2,i+1)-2) i^2+2^i] //2^(i-1)+1 <= k <= 2^i //===> stt= i^2 + (k-2^(i-1)) neu i>1 // stt=k-1 neu i=1 printf("%d\n",i); if(i==1) printf("%lld",k-1); else printf("%1.0f",i*i+(k-pow(2,i-1))); getch(); return 0; }