PS:换了一种方式 希望大家喜欢 2333

/**
code by: zstu wxk
time: 2019/03/01
Problem Link: http://codeforces.com/contest/1130/problem/E
solve:
如果构造的数列是 0 0 0 0 0 0 0 -1 + + + +(+代表大于0的数)
那么 find_answer = sum(+) * len_+
实际上的答案为 tot_len * [sum(+) - 1]
即: sum(+) * len_+ + k = tot_len * [sum(+) - 1]
接下来就是枚举tot_len就好了
**/
#include<bits/stdc++.h>
using namespace std;
#define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
#define LL long long
#define ULL unsigned LL
#define fi first
#define se second
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lch(x) tr[x].son[0]
#define rch(x) tr[x].son[1]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef pair<int,int> pll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL _INF = 0xc0c0c0c0c0c0c0c0;
const LL mod = (int)1e9+;
const int N = 1e5 + ;
int n, k, t1, t2;
int a[N];
bool check(int x){
for(int i = ; i * i <= x; ++i){
if(x % i == ){
t1 = i, t2 = x/i;
t1 = n - t1;
if(t1 < n - && t2 < 1e6 * t1)
return true;
}
}
return false;
}
void Ac(){
n = ;
memset(a, , sizeof a);
for(n = ; n >= ; --n){
if(check(n+k)){
for(int i = ; i <= t1; ++i){
if(t2 >= 1e6){
a[i] = 1e6;
t2 -= 1e6;
}
else{
a[i] = t2;
t2 = ;
}
}
a[t1+] = -;
printf("%d\n", n);
reverse(a+, a++n);
for(int i = ; i <= n; ++i){
printf("%d ", a[i]);
}
break;
}
}
}
int main(){
while(~scanf("%d", &k)){
Ac();
}
return ;
}

最新文章

  1. 基于Python+Django的Kubernetes集群管理平台
  2. 【11_83】Remove Duplicates from Sorted List
  3. ArcEngine中License权限等级更改的问题
  4. EF Code First教程-01 创建一个简单的Code First程序
  5. 使用zend studio配置Xdebug调试PHP教程
  6. 对FileUpload文件上传控件的一些使用方法说明
  7. 接入新浪、腾讯微博和人人网的Android客户端实例 接入新浪、腾讯微博和人人网的Android客户端实例
  8. WIP_DISCRETE_JOBS.STATUS_TYPE
  9. MyPhone
  10. Linux目录树详细说明
  11. VideoView的视频播放
  12. SDWebImage源码解读之分类
  13. ue4(c++) 按钮中的文字居中的问题
  14. AttributeError: &#39;int&#39; object has no attribute &#39;log&#39;
  15. spring boot + vue + element-ui全栈开发入门——windows开发环境
  16. SVN报E155024: Invalid relocation destination
  17. 易爆物D305
  18. Iview Modal 点击确定就关闭,我想禁止关闭该怎么办呢?
  19. 跟敲MySQL数据库实用教程
  20. 跨域iframe如何通信

热门文章

  1. java遍历所有目录和文件
  2. QRCode生成二维码,jq QRCode生成二维码,QRCode生成电子名片
  3. JAVA基础——Switch条件语句
  4. Hystrix超时测试
  5. ASP.NET Core MVC 之控制器(Controller)
  6. 自定义markdown代码高亮显示-cnblog
  7. 使用ArrayPool池化大型数组(翻译)
  8. 【干货】基于镜像部署的Gitlab-CI/CD实践和坑位指南
  9. Yii2 基础模板前后台登录分离
  10. net core Webapi基础工程搭建(四)——日志功能log4net