Problem Solution

1 solutions

  • 0
    @ 2024-07-15 21:34:20

    #include <bits/stdc++.h>
    using namespace std;
    #define SC scanf
    #define PF printf
    #define ull unsigned long long
    #define ld long double
    #define F first
    #define S second
    #define pb push_back
    #define sort_a(a) sort(a.begin(),a.end());
    #define sort_d(a) sort(a.rbegin(),a.rend());
    #define READ(f) freopen(f, "r", stdin)
    #define WRITE(f) freopen(f, "w", stdout)
    #define rev(s) reverse(s.begin(),s.end())
    #define P(ok) cout << (ok ? "YES\n": "NO\n")
    #define Heart ios_base :: sync_with_stdio(false); cin.tie(NULL);
    #define ll long long
    typedef pair< ll , ll> PII;
    vector < int > Ans ;
    void preCal(){
    for(int i = 6 ; i <= 100000 ; i++){
    if(i % 6 == 0 || i % 10 == 0 || i % 15 == 0) Ans.pb(i) ;
    }
    }
    void solve()
    {
    int n ; cin >> n ;
    if(n == 3) {
    cout << "6 10 15\n" ;
    }
    else{
    for(int i = 0 ; i < n ; i++) cout << Ans[i] << " " ; cout << "\n" ;
    }

    }
    int main()
    {
    Heart
    preCal() ;
    //READ("in.txt") ;
    //WRITE("out.txt") ;
    int t ; cin >> t ; while(t--) solve() ;
    }

  • 1

Information

ID
1070
Difficulty
7
Category
Number_Theory Click to Show
Tags
# Submissions
79
Accepted
14
Accepted Ratio
18%
Uploaded By