Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ****revpro**** */
- // #pragma GCC target ("avx2")
- // #pragma GCC optimization ("O3")
- // #pragma GCC optimization ("unroll-loops")
- #include<bits/stdc++.h>
- #define ll long long
- #define pb push_back
- #define endl '\n'
- #define pii pair<ll,ll>
- #define vi vector<ll>
- #define all(a) (a).begin(),(a).end()
- #define F first
- #define S second
- #define sz(x) (ll)x.size()
- #define hell 1000000007
- #define rep(i,a,b) for(ll i=a;i<b;i++)
- #define repr(i,a,b) for(ll i=b-1;i>=a;i--)
- #define lbnd lower_bound
- #define ubnd upper_bound
- #define bs binary_search
- #define mp make_pair
- #define present(c,x) ((c).find(x) != (c).end())
- #define cpresent(c,x) (find(all(c),x) != (c).end())
- #define mii map<ll,ll>
- using namespace std;
- #define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
- #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define N 100005
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- #define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update>
- signed main()
- {
- /***********************************/
- unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
- mt19937_64 generator (seed);
- /***********************************/
- #ifndef ONLINE_JUDGE
- // for getting input from input.txt
- freopen("input.txt", "r", stdin);
- // // for writing output to output.txt
- // freopen("output1.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int TESTS=1;
- while(TESTS--)
- {
- ll n,x;
- cin>>n>>x;
- ll mn=hell;
- bitset <N> ans,tmp,lst,pres;
- rep(i,0,N) lst[i]=1;
- rep(i,0,n)
- {
- ll y;
- cin>>y;
- mn=min(mn,y);
- pres[y]=1;
- ans[x%y]=1;
- }
- repr(i,1,N)
- {
- lst[i]=0;
- if(pres[i])
- {
- tmp=ans;
- for(ll j=0;((1<<j)*i)<N;j++)
- tmp=tmp|(tmp>>((1<<j)*i));
- tmp=tmp&lst;
- ans=ans|tmp;
- }
- }
- ll cnt=0;
- pres.reset();
- rep(i,0,N) if((ans[i]==1)) pres[i%mn]=1;
- cout<<pres.count()<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment