Vector1239's blog

By Vector1239, history, 2 years ago, In English
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<algorithm>
using namespace std;
int getGCD(int x,int y){
    //gcd(a,b) gcd(b,amod b)
    if(y==0){
        return x;
    }
    else{
        return getGCD(y,x%y);
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,c,l,r,a;
        c=1;
        cin>>n>>l>>r;
        vector<int> v;
        set<int> num;
        num.insert(getGCD(c,l));
        v.push_back(l);
        c++;
        while(c<=n && l<=r){
            if(num.find(getGCD(c,l))==num.end()){
                num.insert(getGCD(c,l));
                v.push_back(l);
                c++;
            }
            else l++;
        }
        if(num.size()==n){
            cout<<"YES"<<endl;
            for(auto &i: v){
                cout<<i<<" ";
            }
        }
        else cout<<"NO";
        cout<<endl;
    }
}

Fails at 2nd test, test case no. 2000+ Wondering which test case isn't covered by this code.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it