10940 Throwing Cards Away II (UVA)

Brute Force  চালাও  আর দেখ  কোন Pattern পাও কি না  ;) । হ্যা ,

 n=1 হলে ans=1

এরপর  থেকে  n  এর  মান  যখন  2 এর  কোন  ঘাতের  সমান  হবে  তখন

ans = n

তা  নাহলে  N  এর  সবচেয়ে  বড়  যে  মানের  জন্য  (n / 2^N )  এর মান  '0'  থেকে  বড়  হয় সেক্ষেত্রে

2^N=2   ( 2^N refers to answer=2 )

2^N+1=4  ( 2^N+1 refers to answer=4 )

2^N+2=6

2^N+i=x

2^N+i=n  হয়ে  গেলে  ans=x হবে।

Comments

Popular posts from this blog

PopIt Serially support page

10405 - Longest Common Subsequence (UVA)