题意

题目链接

Sol

对构造一无所知。。。

题解的方法比较神仙,,设第一个位置为\(-1\),\(S = \sum_{i=1}^n a_i\)

那么我们要让\(N * S - (N - 1) * (S + 1) = K\)

固定\(N\)之后可以直接解出\(S\)。。。

  1. #include<bits/stdc++.h>
  2. #define Pair pair<LL, LL>
  3. #define MP(x, y) make_pair(x, y)
  4. #define fi first
  5. #define se second
  6. #define LL long long
  7. #define Fin(x) {freopen(#x".in","r",stdin);}
  8. #define Fout(x) {freopen(#x".out","w",stdout);}
  9. using namespace std;
  10. const int MAXN = 2001, mod =666623333, INF = 1e9 + 10;
  11. const double eps = 1e-9;
  12. template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
  13. template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
  14. template <typename A, typename B> inline LL add(A x, B y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
  15. template <typename A, typename B> inline void add2(A &x, B y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
  16. template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
  17. template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
  18. template <typename A> inline void debug(A a){cout << a << '\n';}
  19. template <typename A> inline LL sqr(A x){return 1ll * x * x;}
  20. inline int read() {
  21. char c = getchar(); int x = 0, f = 1;
  22. while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
  23. while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  24. return x * f;
  25. }
  26. int N = 2000, a[MAXN];
  27. signed main() {
  28. a[1] = -1;
  29. int Lim = 1e6, K = read(), S = K + N;
  30. for(int i = 2; i <= N; i++)
  31. if(S > Lim) a[i] = Lim, S -= Lim;
  32. else {a[i] = S; break;}
  33. cout << N << '\n';
  34. for(int i = 1; i <= N; i++) cout << a[i] << " ";
  35. return 0;
  36. }

cf1130E. Wrong Answer(构造)的更多相关文章

  1. CF1130E Wrong Answer

    E Wrong Answer 注意到 \(n\geq 2\) 时才可能有解,可以按如下方式构造一个 \(a_{1,2\dots n}\): 令 \(a_1=-1\) ,而后面的数都为正.记 \(s=\ ...

  2. 解题:CF1130E Wrong Answer

    题面 巧妙构造题 这种题一定要限制一个条件,使得在这个条件下能推出要叉的代码的式子 令序列$a$的第一个元素为负,其余元素为正,且保证序列中至少有两个元素,那么Alice的代码将会从第二个元素开始计算 ...

  3. Codeforces 1130 E.Wrong Answer 构造

    题目要求构造一组数据使得题目给出代码的anwser和正确答案恰好相差k,我们记题目给出代码的输出为ans1,正确答案为ans2. 我们假设已经有总和为s的p个正数,使得此时的ans1=ans2=s*p ...

  4. CF Round 542 Div1.

    B. Wrong Answer 构造一个长度为 2000 的数组,满足最大“子段和 $\times$ 子段长度”比最大子段和刚好大 k sol: 一个比较好的构造方法: 令数组总和为 $S$,然后构造 ...

  5. Java之多线程同步基础

    java学习的道路上呢总有一些麻烦的东西需要花费一些时间去理解,比如个人认为不好搞的多线程. 线程是并列运行的 因为是并列运行,所以有时候会发生资源抢占,从而导致参数变化; 比如酱紫 package ...

  6. CTF 入门笔记

    站点:http://www.moctf.com/ web1:水题非常简单的题目,直接F12查看元素即可,在HTML代码中,flag被注释了. web2:水题 该题的核心 就是通过HTML代码对输入框进 ...

  7. Codeforces Round #381 (Div. 2) A B C 水 构造

    A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input stand ...

  8. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

  9. codeforces 577E E. Points on Plane(构造+分块)

    题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

随机推荐

  1. Django 通过 mongoengine 连接 MongoDB 进而使用orm进行CRUD

    一. 在python脚本中, 我们通常可以使用pymongo模块实现与mongodb数据库的交互, 但是在使用Django框架进行定制开发的web server 项目中, 仍然使用pymongo模块的 ...

  2. Android之ListView,AsyncTask,GridView,CardView,本地数据存储,SQLite数据库

    版权声明:未经博主允许不得转载 补充 补充上一节,使用ListView是用来显示列表项的,使用ListView需要两个xml文件,一个是列表布局,一个是单个列表项的布局.如我们要在要显示系统所有app ...

  3. Shell-1--概念

  4. C#中关于as关键字的使用

    我们在实际编码中有时会用到as关键字来将对象转换为指定类型,与is类型不同的是,is关键字是用于检查对象是否与给定类型兼容,如果兼容就返回true,如果不兼容就返回false.而as关键字会直接进行类 ...

  5. jvm-垃圾回收gc简介+jvm内存模型简介

    gc是jvm自动执行的,自动清除jvm内存垃圾,无须人为干涉,虽然方便了程序员的开发,但同时增加了开发人员对内存的不可控性. 1.jvm内存模型简介 jvm是在计算机系统上又虚拟出来的一个伪计算机系统 ...

  6. 【sping揭秘】16、@After(finally) 但是这个实在afterturning之前执行

    package cn.cutter.start.bean; import org.apache.commons.logging.Log; import org.apache.commons.loggi ...

  7. java开发,年薪15W的你和年薪50W的他的差距

      在这个IT系统动辄就是上亿流量的时代,Java作为大数据时代应用最广泛的语言,诞生了一批又一批的新技术,包括HBase.Hadoop.MQ.Netty.SpringCloud等等 .   一些独角 ...

  8. HDU 6044--Limited Permutation(搜索+组合数+逆元)

    题目链接 Problem Description As to a permutation p1,p2,⋯,pn from 1 to n, it is uncomplicated for each 1≤ ...

  9. 21天打造分布式爬虫-Crawl类爬取小程序社区(八)

    8.1.Crawl的用法实战 新建项目 scrapy startproject wxapp scrapy genspider -t crawl wxapp_spider "wxapp-uni ...

  10. 与LINQ有关的语言特性

    在说LINQ之前必须先说说几个重要的C#语言特性 一:与LINQ有关的语言特性 1.隐式类型 (1)源起 在隐式类型出现之前, 我们在声明一个变量的时候, 总是要为一个变量指定他的类型 甚至在fore ...