sacgajcvs

Untitled

Feb 16th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. /* ****revpro**** */
  2. // #pragma GCC target ("avx2")
  3. // #pragma GCC optimization ("O3")
  4. // #pragma GCC optimization ("unroll-loops")
  5. #include<bits/stdc++.h>
  6. #define ll long long
  7. #define pb push_back
  8. #define endl '\n'
  9. #define pii pair<ll,ll>
  10. #define vi vector<ll>
  11. #define all(a) (a).begin(),(a).end()
  12. #define F first
  13. #define S second
  14. #define sz(x) (ll)x.size()
  15. #define hell 1000000007
  16. #define rep(i,a,b) for(ll i=a;i<b;i++)
  17. #define repr(i,a,b) for(ll i=b-1;i>=a;i--)
  18. #define lbnd lower_bound
  19. #define ubnd upper_bound
  20. #define bs binary_search
  21. #define mp make_pair
  22. #define present(c,x) ((c).find(x) != (c).end())
  23. #define cpresent(c,x) (find(all(c),x) != (c).end())
  24. #define mii map<ll,ll>
  25. using namespace std;
  26.  
  27. #define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
  28. #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  29. #define N 100005
  30. #include <ext/pb_ds/assoc_container.hpp>
  31. #include <ext/pb_ds/tree_policy.hpp>
  32. using namespace __gnu_pbds;
  33. #define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update>
  34. signed main()
  35. {
  36.  
  37. /***********************************/
  38. unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
  39. mt19937_64 generator (seed);
  40. /***********************************/
  41. #ifndef ONLINE_JUDGE
  42. // for getting input from input.txt
  43. freopen("input.txt", "r", stdin);
  44. // // for writing output to output.txt
  45. // freopen("output1.txt", "w", stdout);
  46. #endif
  47. ios_base::sync_with_stdio(false);
  48. cin.tie(0);
  49. cout.tie(0);
  50. int TESTS=1;
  51. while(TESTS--)
  52. {
  53. ll n,x;
  54. cin>>n>>x;
  55. ll mn=hell;
  56. bitset <N> ans,tmp,lst,pres;
  57. rep(i,0,N) lst[i]=1;
  58. rep(i,0,n)
  59. {
  60. ll y;
  61. cin>>y;
  62. mn=min(mn,y);
  63. pres[y]=1;
  64. ans[x%y]=1;
  65. }
  66. repr(i,1,N)
  67. {
  68. lst[i]=0;
  69. if(pres[i])
  70. {
  71. tmp=ans;
  72. for(ll j=0;((1<<j)*i)<N;j++)
  73. tmp=tmp|(tmp>>((1<<j)*i));
  74. tmp=tmp&lst;
  75. ans=ans|tmp;
  76. }
  77. }
  78. ll cnt=0;
  79. pres.reset();
  80. rep(i,0,N) if((ans[i]==1)) pres[i%mn]=1;
  81. cout<<pres.count()<<endl;
  82. }
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment