当前位置:网站首页>Educational Codeforces Round 20 C. Maximal GCD

Educational Codeforces Round 20 C. Maximal GCD

2022-06-09 05:56:00 No toast

#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,siz eof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

#define int long long 

const int maxn = 1e5+2;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int n,k;
std::vector<int> v;
void solve(){
    
    cin>>n>>k;
    for(int i=1;i*i<=n;i++){
    
        if(n%i==0){
    
             v.push_back(i);
             v.push_back(n/i);
        }
    }
    if(k>6e5){
    
        cout<<-1<<endl;
        return;
    }
    int nd=k*(k+1)/2;
    // cout<<nd<<endl;
    // return ;

    sort(v.begin(), v.end());
    for(int i=v.size()-1;i>=0;i--){
    
        int cnt=n/v[i];
        if(cnt>=nd){
    
            for(int j=1;j<=k-1;j++){
    
                printf("%lld ",j*v[i]);
            }
            // cout<<(cnt-(k-1)*k/2)*v[i]<<endl;
            printf("%lld\n",(cnt-(k-1)*k/2)*v[i]);
            return ;
        }
    }
    cout<<-1<<endl;
    return;
}

int32_t main()
{
    
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    
    // printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}
原网站

版权声明
本文为[No toast]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090555059122.html