Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define nl "\n"
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define ull unsigned ll
- #define RV return void
- #define sz(x) int(x.size())
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define fixed(n) fixed << setprecision(n)
- #define cin(v) for (auto&i:v) cin >> i;
- #define cout(v) for (auto&i:v) cout << i << " ";
- #define clr(memo, x) memset(memo, x, sizeof memo)
- #define FastCode ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- void Zainab(){
- // #ifndef ONLINE_JUDGE
- // freopen("hobz.in", "r", stdin);
- // freopen("longpath.out", "w", stdout);
- // #endif
- }
- const ll N = 1e6 ;
- ll spf[N+5];
- void mod_Sieve(){
- iota(spf , spf +N+5 , 0);
- spf[0]=spf[1]=-1;
- for(ll i = 2 ; i * i <= N ; i++)
- if(spf[i]==i)
- for(ll j = i * i ; j <= N ; j+=i)
- if(spf[j]==j)
- spf[j]=i;
- }
- void myCode( ){
- ll q ;
- cin >> q;
- mod_Sieve();
- map < ll , ll > mp ;
- ll last =1;
- while(q--){
- int op ; cin >> op;
- if(op==1){
- ll x ; cin >> x;
- while(x > 1){
- mp[spf[x]]++;
- x/= spf[x];
- }
- }
- else{
- ll x ; cin >> x;
- if(x <= last) {
- cout << "YES\n";
- continue;
- }
- bool flag = 0;
- for(ll i =last+1 ; i <= x ; i++){
- ll t = i;
- while(t > 1){
- if(mp[spf[t]] > 0){
- mp[spf[t]]--;
- }
- else {
- // cout << t << " " << spf[t] << nl;
- cout << "NO\n";
- flag=1;
- break;
- }
- t/=spf[t];
- }
- if(flag) break;
- last = max(last , i);
- }
- if(!flag) cout << "YES\n";
- }
- }
- // for(auto& [f,s] : mp) cout << f << " " << s << nl;
- }
- int main(){
- FastCode ;
- // Zainab();
- int testCase=1;
- // cin >> testCase ;
- for(int i=1 ; i<= testCase ; i++)
- myCode();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement