zoukankan      html  css  js  c++  java
  • Kate and imperfection CodeForces

    Kate has a set SS of nn integers {1,,n}{1,…,n}.

    She thinks that imperfection of a subset MSM⊆S is equal to the maximum of gcd(a,b)gcd(a,b) over all pairs (a,b)(a,b) such that both aa and bb are in MM and aba≠b.

    Kate is a very neat girl and for each k{2,,n}k∈{2,…,n} she wants to find a subset that has the smallest imperfection among all subsets in SS of size kk. There can be more than one subset with the smallest imperfection and the same size, but you don't need to worry about it. Kate wants to find all the subsets herself, but she needs your help to find the smallest possible imperfection for each size kk, will name it IkIk.

    Please, help Kate to find I2I2, I3I3, ..., InIn.

    Input

    The first and only line in the input consists of only one integer nn (2n51052≤n≤5⋅105)  — the size of the given set SS.

    Output

    Output contains only one line that includes n1n−1 integers: I2I2, I3I3, ..., InIn.

    Examples

    Input
    2
    
    Output
    1 
    Input
    3
    
    Output
    1 1 

    Note

    First sample: answer is 1, because gcd(1,2)=1gcd(1,2)=1.

    Second sample: there are subsets of SS with sizes 2,32,3 with imperfection equal to 1. For example, {2,3}{2,3} and {1,2,3}{1,2,3}.

    #include <bits/stdc++.h>
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include<cstring>
    #include <algorithm>
    #include <queue>
    #include<map>
    #include<set>
    #include<vector>
    using namespace std;
    typedef long long ll;
    const int inf = 1e9;
    const int mod = 1000000007;
    const int mx = 5e5+10; //check the limits, dummy
    typedef pair<int, int> pa;
    const double PI = acos(-1);
    ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
    #define swa(a,b) a^=b^=a^=b
    #define re(i,a,b) for(int i=(a),_=(b);i<_;i++)
    #define rb(i,a,b) for(int i=(a),_=(b);i>=_;i--)
    #define clr(a) memset(a, -1, sizeof(a))
    #define lowbit(x) ((x)&(x-1))
    #define mkp make_pai
    void sc(int& x) { scanf("%d", &x); }void sc(int64_t& x) { scanf("%lld", &x); }void sc(double& x) { scanf("%lf", &x); }void sc(char& x) { scanf(" %c", &x); }void sc(char* x) { scanf("%s", x); }
    int n, m, k,ans=0,t,p,x;
    int a[mx];
    vector<int>maxdiv;
    void fuck(int limit) {
        maxdiv.assign(limit + 1, 0);
        maxdiv[0] = limit + 10;
        maxdiv[1] = 1;
        re(i, 2, limit + 1) {
            if (maxdiv[i])continue;
            for (int j = i; j <=limit; j+=i)
            {
                if (maxdiv[j])continue;
                maxdiv[j] = j / i;
            }
        }
    }
    int main()
    {
        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        cin >> n;
        fuck(n);
        sort(maxdiv.begin(), maxdiv.end());
        re(i, 1, n)cout << maxdiv[i] << ' ';
        return 0;
    }
  • 相关阅读:
    lookup:ID列
    分享几篇文章
    怎样无限制使用smartgit ?
    C++ Win32控制台应用程序捕捉关闭事件
    mt4 在K线上 放文字
    变色指标
    用windows 打包 证书
    监管fca asic nfa 啥啥啥
    sublime 3 build 3126 code ,压缩包在我的360企业云盘里,搜sublime
    个人作业收官——软件工程实践总结
  • 原文地址:https://www.cnblogs.com/xxxsans/p/12771694.html
Copyright © 2011-2022 走看看