cf1130E. Wrong Answer(构造)
题意
Sol
对构造一无所知。。。
题解的方法比较神仙,,设第一个位置为\(-1\),\(S = \sum_{i=1}^n a_i\)
那么我们要让\(N * S - (N - 1) * (S + 1) = K\)
固定\(N\)之后可以直接解出\(S\)。。。
#include<bits/stdc++.h>
#define Pair pair<LL, LL>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define LL long long
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 2001, mod =666623333, INF = 1e9 + 10;
const double eps = 1e-9;
template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
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;}
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);}
template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename A> inline void debug(A a){cout << a << '\n';}
template <typename A> inline LL sqr(A x){return 1ll * x * x;}
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N = 2000, a[MAXN];
signed main() {
a[1] = -1;
int Lim = 1e6, K = read(), S = K + N;
for(int i = 2; i <= N; i++)
if(S > Lim) a[i] = Lim, S -= Lim;
else {a[i] = S; break;}
cout << N << '\n';
for(int i = 1; i <= N; i++) cout << a[i] << " ";
return 0;
}
cf1130E. Wrong Answer(构造)的更多相关文章
- CF1130E Wrong Answer
E Wrong Answer 注意到 \(n\geq 2\) 时才可能有解,可以按如下方式构造一个 \(a_{1,2\dots n}\): 令 \(a_1=-1\) ,而后面的数都为正.记 \(s=\ ...
- 解题:CF1130E Wrong Answer
题面 巧妙构造题 这种题一定要限制一个条件,使得在这个条件下能推出要叉的代码的式子 令序列$a$的第一个元素为负,其余元素为正,且保证序列中至少有两个元素,那么Alice的代码将会从第二个元素开始计算 ...
- Codeforces 1130 E.Wrong Answer 构造
题目要求构造一组数据使得题目给出代码的anwser和正确答案恰好相差k,我们记题目给出代码的输出为ans1,正确答案为ans2. 我们假设已经有总和为s的p个正数,使得此时的ans1=ans2=s*p ...
- CF Round 542 Div1.
B. Wrong Answer 构造一个长度为 2000 的数组,满足最大“子段和 $\times$ 子段长度”比最大子段和刚好大 k sol: 一个比较好的构造方法: 令数组总和为 $S$,然后构造 ...
- Java之多线程同步基础
java学习的道路上呢总有一些麻烦的东西需要花费一些时间去理解,比如个人认为不好搞的多线程. 线程是并列运行的 因为是并列运行,所以有时候会发生资源抢占,从而导致参数变化; 比如酱紫 package ...
- CTF 入门笔记
站点:http://www.moctf.com/ web1:水题非常简单的题目,直接F12查看元素即可,在HTML代码中,flag被注释了. web2:水题 该题的核心 就是通过HTML代码对输入框进 ...
- 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 ...
- 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 ...
- codeforces 577E E. Points on Plane(构造+分块)
题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
随机推荐
- 分享Azure DevOps技术,来微信群吧!
现在QQ用户越来越少,基本上都转移到微信上了. 讨论问题,动不动就来一个微信群.下面这样几百人的微信群,专门讨论Azure DevOps (TFS)技术,你加入了么? 还等什么,扫描吧!
- HTML各个版本以及对应doctype
HTML发布的正式历史版本: 1.HTML2.0 2.HTML3.2 3.HTML4.0 4.HTML4.01 5.XHTML1.0 6.XHTML1.1 7.XHTML2.0 中途放弃,未完成 8 ...
- MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause
MySQL[Err]1055 上次MySQL5.7.19主从建立完成之后,所有的测试都是在MySQL命令行下进行的,最近用Navicat Premium进行MySQL的连接,然后在插入数据的时候MyS ...
- jQuery基础与JavaScript与CSS交互-第五章
目录 JavaScript框架种类及其优缺点 jQuery库 jQuery对象$ 掌握基本选择器 掌握过滤选择器 掌握表单选择器 RIA技术 常见的RIA技术 Ajax Sliverlight Fle ...
- JavaScript中子类调用父类方法的实现
一.前言 最近在项目中,前端框架使用JavaScript面向对象编程,遇到了诸多问题,其中最典型的问题就是子类调用父类(super class)同名方法,也就是如C#中子类中调用父类函数base.** ...
- Testing - 软件测试知识梳理 - 比较质量保证(QA)与质量控制(QC)
QA QC QM 概念 Quality Assurance (质量保证) Quality Control (质量控制) Quality Manage (质量管理) 定义 为达到质量要求所采取的作业技术 ...
- druid的关键参数+数据库连接池运行原理
minEvictableIdleTimeMillis :连接保持空闲而不被驱逐的最长存活时间.(默认30分钟) Destory线程中如果检测到当前连接的最后活跃时间和当前时间的差值大于minEvi ...
- web.xml简介
用于配置Web应用的相关信息,如:监听器(listener).过滤器(filter). Servlet.相关参数.会话超时时间.安全验证方式.错误页面等.例如: Servlet 3中的异步处理指的是什 ...
- vi/vim编辑器的使用
命令模式下操作替换字符:%s/str1/str2/g删除全部内容:%d不保存退出:q!保存退出:wq! 执行shell命令:!command 如!ls -l 在下一行插入shell命令执行 ...
- 从零开始学 Web 之 CSS3(四)边框图片,过渡
大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...