Want to know whats wrong in #808(Div 2) B — Difference of GCDs code.

Правка en1, от Vector1239, 2022-07-20 18:45:15
#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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Vector1239 2022-07-20 18:45:15 1143 Initial revision (published)