题目链接:http://codeforces.com/contest/803/problem/C


中了若干trick之后才过...

  k个数的严格递增序列最小权值和就是${n*(n+1)/2}$,枚举这些数字增加的倍数x,使得序列变成${x,2x,3x...kx}$,然后再使最后一个数字变大满足要求就可以了,枚举的复杂度是根号$n$的。

  要注意枚举倍数$x$的时候还要顺便枚举了$n/x$,然后${n*(n+1)/2}$这个东西是会爆long long的。

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long
#define LDB long double
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,cha,k; inline int getint()
{
int w=,q=; char c=getchar();
while((c<'' || c>'') && c!='-') c=getchar(); if(c=='-') q=,c=getchar();
while (c>='' && c<='') w=w*+c-'', c=getchar(); return q ? -w : w;
} llg find(llg x)
{
llg up=sqrt(x),Ans=-;
for (llg i=;i<=up;i++)
if (x%i==)
{
if ((LDB)x*/(LDB)i/(LDB)k>=(LDB)(k+) && i>Ans) {Ans=i; cha=x/i-(k*(k+))/;}
if ((LDB)i*/(LDB)k>=(LDB)(k+) && x/i>Ans) {Ans=x/i; cha=i-(k*(k+))/;}
}
return Ans;
} int main()
{
yyj("C");
cin>>n>>k;
llg val=find(n);
if (val==-) {cout<<-; return ;}
for (llg i=;i<k;i++) printf("%lld ",i*val);
printf("%lld",(k+cha)*val);
return ;
}

Codeforces 803C. Maximal GCD的更多相关文章

  1. codeforces 803C Maximal GCD(GCD数学)

    Maximal GCD 题目链接:http://codeforces.com/contest/803/problem/C 题目大意: 给你n,k(1<=n,k<=1e10). 要你输出k个 ...

  2. Codeforces 803C. Maximal GCD 二分

    C. Maximal GCD time limit per test: 1 second memory limit per test: 256 megabytes input: standard in ...

  3. CodeForces - 803C Maximal GCD 【构造】

    You are given positive integer number n. You should create such strictly increasing sequence of k po ...

  4. Codeforces H. Maximal GCD(贪心)

    题目描述: H. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. CodeFoorces 803C Maximal GCD

    枚举. 枚举$gcd$,然后计算剩下的那个数能不能分成$k$个递增的数. #include <iostream> #include <cstdio> #include < ...

  6. 【数学】codeforces C. Maximal GCD

    http://codeforces.com/contest/803/problem/C [题意] 给定两个数n,k(1 ≤ n, k ≤ 10^10) 要你输出k个数,满足以下条件: ①这k个数之和等 ...

  7. AC日记——Maximal GCD codeforces 803c

    803C - Maximal GCD 思路: 最大的公约数是n的因数: 然后看范围k<=10^10; 单是答案都会超时: 但是,仔细读题会发现,n必须不小于k*(k+1)/2: 所以,当k不小于 ...

  8. Maximal GCD CodeForces - 803C (数论+思维优化)

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. Educational Codeforces Round 20 C. Maximal GCD

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. 【LeetCode每天一题】Set Matrix Zeroes(设置0矩阵)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Exampl ...

  2. Cocos Creator JS web平台复制粘贴代码(亲测可用)

    Cocos Creator JS web平台复制粘贴代码(亲测可用) 1 webCopyString: function(str){ var input = str; const el = docum ...

  3. git上clone需要ssh时

    在命令行中输入ssh-keygen -t rsa -C "your_email@example.com" 然后使用编辑器打开id_rsa.pub文件,复制里面的ssh

  4. FB面经Prepare: Dot Product

    Conduct Dot Product of two large Vectors 1. two pointers 2. hashmap 3. 如果没有额外空间,如果一个很大,一个很小,适合scan小的 ...

  5. Pocket Gem OA: Path Finder

    1. 有向图 找所有start node到end node之间的路径 输入是一个txt 形式如下: A E A : B C D. B : C C : E D : B. 输出一个List<Stri ...

  6. C#中DataTable与XML格式的相互转换

    1.DataTable转换成XML public string ConvertDataTableToXML(DataTable xmlDS) { MemoryStream stream = null; ...

  7. Selenium Edge Driver Python 自动化测试

    Finally I got it. 没有自动化过edge,今天被小坑了一下,但是还好现在弄好了. 1. 查看edge 版本,我的是14.14393 2. https://developer.micro ...

  8. Python生成器的原理及使用

    '''1,什么是生成器? 函数内但凡有一个yield关键字, 再调用函数就不会执行函数代码,得到的返回值就是一个生成器对象 生成器本身就是一种迭代器 next(g)过程: 会触发生成器g所对应的函数的 ...

  9. DotNetty网络通信框架学习之源码分析

    DotNetty网络通信框架学习之源码分析 有关DotNetty框架,网上的详细资料不是很多,有不多的几个博友做了简单的介绍,也没有做深入的探究,我也根据源码中提供的demo做一下记录,方便后期查阅. ...

  10. 对java多态的理解

    java多态,如何理解父类引用指向子类对象 要理解多态性,首先要知道什么是“向上转型”. 我定义了一个子类Cat,它继承了Animal类,那么后者就是前者是父类.我可以通过 Cat c = new C ...