Falak_Ahmed_Shakib

recourtion

Nov 26th, 2020 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef pair<ll,ll> pll;
  5. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
  6. #define fi first
  7. #define se second
  8. #define pb push_back
  9. ll const MOD=1000000007;
  10. #define eb emplace_back
  11. const int N=10000005;
  12.  
  13.  
  14. void call(ll n)
  15. {
  16. if(n<=1)
  17. {
  18. cout<<n;
  19. return ;
  20. }
  21.  
  22. call(n/2);
  23.  
  24. cout<<n%2;
  25.  
  26. return ;
  27.  
  28. }
  29.  
  30.  
  31. int main()
  32. {
  33. ll n;
  34. cin>>n;
  35. call(n);
  36.  
  37.  
  38. }
  39.  
  40. ''''''''''''''''''''''''''''''''
  41.  
  42. #include<bits/stdc++.h>
  43. using namespace std;
  44. using ll = long long;
  45. #define pb push_back
  46. #define ff first
  47. #define ss second
  48. #define pb push_back
  49. #define eb emplace_back
  50. typedef pair<ll,ll>pll;
  51. typedef pair<ll,pair<ll,ll>>plll;
  52. const ll mod=1e9+7;
  53. const ll Max=2e5+7;
  54. pll ara[Max+1];
  55. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
  56. bool f;
  57. ll tar;
  58. void call(ll n)
  59. {
  60. if(n==tar)
  61. {
  62. f=true;
  63. return;
  64. }
  65.  
  66. if(n>tar)return;;
  67.  
  68. call(n+3);
  69. call(n+7);
  70.  
  71.  
  72.  
  73.  
  74. }
  75.  
  76.  
  77. int main()
  78. {
  79. fastread();
  80.  
  81. ll t;
  82.  
  83. cin>>t;
  84. ll ara[102];
  85. for(ll i=1;i<=100;i++)
  86. {
  87. f=false;
  88. tar=i;
  89.  
  90. call(0);
  91.  
  92. if(f)ara[i]=1;
  93. else ara[i]=0;
  94.  
  95. }
  96.  
  97. while(t--)
  98. {
  99.  
  100.  
  101. ll a;
  102. cin>>a;
  103. if(ara[a])cout<<"YES"<<endl;
  104. else cout<<"NO"<<endl;
  105.  
  106. }
  107.  
  108. }
  109. pb link :https://codeforces.com/contest/903/problem/A
  110.  
  111.  
Add Comment
Please, Sign In to add comment