Advertisement
jakaria_hossain

Codechef - Byte to bit

Oct 9th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. unsigned long long ara[1601];
  4. void seive()
  5. {
  6. ara[0]=0;
  7. ara[1]=1;
  8. cout<<ara[0]<<" "<<ara[1]<<endl;
  9. for(unsigned long long i=2; i<=1600; i++)
  10. {
  11. ara[i]=ara[i-1]*2;
  12. cout<<ara[i]<<endl;
  13. }
  14.  
  15.  
  16. }
  17. int main()
  18. {
  19. //seive();
  20. int t;
  21. scanf("%d",&t);
  22.  
  23. while(t--)
  24. {
  25. long long n;
  26. scanf("%lld",&n);
  27. long long bit=1,nibble=1,byte=1,x,y;
  28. if(n<=2)
  29. {
  30. bit=1,byte=0,nibble=0;
  31. }
  32. else if(2<n && n<=10)
  33. {
  34. bit=0,nibble=1,byte=0;
  35. }
  36. else if(10<n && n<=26)
  37. {
  38. bit=0,nibble=0,byte=1;
  39. }
  40. else
  41. for(x=27; x<=n; x++)
  42. {
  43. y=x%26;
  44. if(y==0)
  45. {
  46. byte=max(nibble,byte);
  47. nibble=0;
  48. bit=0;
  49. }
  50. else if(y>0 && y<=2)
  51. {
  52. bit=max(byte*2,bit);
  53. nibble=0;
  54. byte=0;
  55. }
  56. else if(y>2 && y<=10)
  57. {
  58. nibble=max(bit,nibble);
  59. bit=0;
  60. byte=0;
  61. }
  62. else
  63. {
  64. byte=max(nibble,byte);
  65. nibble=0;
  66. bit=0;
  67. }
  68. }
  69. printf("%lld %lld %lld\n",bit,nibble,byte);
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement