Codeforces Round #808 (Div. 2) 1708B. Difference of GCDs Solution
Problem Link: https://codeforces.com/contest/1708/problem/B
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long int
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int n, l, r, i, t, j, f;
- cin >> t;
- while (t--) {
- cin >> n >> l >> r;
- std::vector<int> v;
- int a,index;
- for( int i = 1 ; i <= n ; i++)
- {
- index=i;
- if(l%index==0)v.push_back(l);
- else
- {
- a=l/index +1;
- a=a*index;
- if(a<=r)v.push_back(a);
- }
- }
- if(v.size()==n)
- {
- cout<<"YES"<<endl;
- for(auto i:v)cout<<i<<" ";
- }
- else
- cout<<"NO";
- cout<<endl;
- }
- }
No comments