题目链接: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. [svc]tcp三次握手四次挥手&tcp的11种状态(半连接)&tcp的time-wait

    TCP的状态转化过程(11种状态)以及TIME_WAIT状态 高性能网络 | 你所不知道的TIME_WAIT和CLOSE_WAIT 我相信很多都遇到过这个问题.一旦有用户在喊:网络变慢了.第一件事情就 ...

  2. (转)手工释放linux内存——/proc/sys/vm/drop_cache

    linux的内存查看: [root@localhost 0.1.0]# free -m                   total       used       free     shared ...

  3. stm32_ADC定时器采样(DMA均值处理数据)

    在有些要求高的场合,需要用到定时器采样.本人在网上没找到合适的源码,于是将自己的思路分享出来,欢迎大家提出意见. 确定ADC采用的通道对应的通道 确定采样对应的引脚(这个在规格书的引脚定义部分可以找到 ...

  4. Mac vs code 快捷键

    control  +  shift  +  L 选中所有匹配的所有单词,光标选中

  5. 计算机网络网络层的IP地址划分及子码

    现在在网络层,即就是TCP/IP协议里的网际互联层,最流行IP协议的就是IPV4.其中IP地址的格式是由32位二进制数字表示的,通常为了人们阅读习惯,将其转换成点分十进制来表示,如:192.168.1 ...

  6. Fiddler抓包【6】_Fiddler Script

    1.安装SyntaxView插件 使用Fiddler Script前需要安装SyntaxView插件: 方式1:Inspectors tab--->Get SyntaxView tab---&g ...

  7. Cpython解释器GIL-多线程执行流程

  8. 单链表反转java代码

    据说单链表反转问题面试中经常问,而链表这个东西相对于数组的确稍微难想象,因此今天纪录一下单链表反转的代码. 1,先定义一个节点类. public class Node { int index; Nod ...

  9. Delphi中Move、CopyMemory操作

    字串转字节数组 一.CopyMemory var s:PAnsiChar; ary:TArray<Byte>; bt:Byte; begin s:='Form Delphi'; SetLe ...

  10. Tengine 安装和说明

    使用tengine要安装nginx.架构为:LTNMT或LTNMP 1. 官网下载源码包 [root@qc_centos7_5 src]# wget http://tengine.taobao.org ...