CF1130E Wrong Answer
E Wrong Answer
- 注意到 \(n\geq 2\) 时才可能有解,可以按如下方式构造一个 \(a_{1,2\dots n}\):
- 令 \(a_1=-1\) ,而后面的数都为正.记 \(s=\sum_{i=2}^{n} a_i\),显然题目中的程序给出的答案是 \(s*(n-1)\) .
- 为使这个答案比正确答案少 \(k\) ,那么正确答案只能是 \((s-1)*n\).
\]
- 由于我们可以放 \(1\) 个 \(-1\) , \(1999\) 个 \(10^6\),此时 \(s-n=1999*10^6-2000>10^9\) ,所以按照上述方法一定可以构造出一组解.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
inline int read()
{
int x=0;
bool pos=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())
if(ch=='-')
pos=0;
for(;isdigit(ch);ch=getchar())
x=x*10+ch-'0';
return pos?x:-x;
}
const int delta=1e6-1;
int ans[2019],n=0;
int main()
{
int k=read();
++k;
ans[++n]=-1;
while(k>=delta)
{
k-=delta;
ans[++n]=delta+1;
}
ans[++n]=k+1;
cout<<n<<endl;
for(int i=1;i<=n;++i)
cout<<ans[i]<<' ';
return 0;
}
CF1130E Wrong Answer的更多相关文章
- cf1130E. Wrong Answer(构造)
题意 题目链接 Sol 对构造一无所知... 题解的方法比较神仙,,设第一个位置为\(-1\),\(S = \sum_{i=1}^n a_i\) 那么我们要让\(N * S - (N - 1) * ( ...
- 解题:CF1130E Wrong Answer
题面 巧妙构造题 这种题一定要限制一个条件,使得在这个条件下能推出要叉的代码的式子 令序列$a$的第一个元素为负,其余元素为正,且保证序列中至少有两个元素,那么Alice的代码将会从第二个元素开始计算 ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- Stack Overflow is a question and answer site
http://stackoverflow.com/ _ Stack Overflow is a question and answer site for professional and enthus ...
- SPOJ GSS2 Can you answer these queries II
Time Limit: 1000MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Description Being a ...
- Question and Answer
1.VS2013使用EntityFrame问题解决办法 解决办法参照博客http://pinter.org/?p=2374 使用到EntityFrame的项目配置文件修改如下: 项目中凡是使用到DbC ...
- 转 https://www.zhihu.com/question/27606493/answer/37447829
著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:梁川链接:https://www.zhihu.com/question/27606493/answer/37447829来源: ...
- hdu 4027 Can you answer these queries?
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4027 Can you answer these queries? Description Proble ...
- GSS4 2713. Can you answer these queries IV 线段树
GSS7 Can you answer these queries IV 题目:给出一个数列,原数列和值不超过1e18,有两种操作: 0 x y:修改区间[x,y]所有数开方后向下调整至最近的整数 1 ...
随机推荐
- Springboot依赖注入 Service类中使用静态变量
@Component public class ServerHandler extends IoHandlerAdapter { @Autowired protected HealthDataServ ...
- JavaScript之右下角广告
网站中,我们都遇到想这样的悬浮广告,我们先给图片设置右下角悬浮属性,关闭按钮键也就是节点的删除: window.onload = function(){ var TipBox = document.g ...
- OpenID 和 OAuth 的区别及第三方登录的安全隐患分析
转自:http://itindex.net/detail/48552-openid-oauth-%E6%96%B9%E7%99%BB 发表时间:2014-03-13 19:09 | 作者:天梯梦 出处 ...
- 英语每日写作---4、VOA慢速英语(翻译+字幕+讲解):专家:城市发展将加剧住房危机
英语每日写作---4.VOA慢速英语(翻译+字幕+讲解):专家:城市发展将加剧住房危机 一.总结 一句话总结: takes place 发生deal with 处理:应付population grow ...
- 引发事件代码封装成OnEventName
引发事件的代码,通常可以封装成“On+事件名称”的方法(On:表示当“什么什么”的时候),如下所示: 1:引发事件代码: if (PropertyChanged != null)//为了实现将数据源的 ...
- 第七天 Linux用户管理、RHEL6.5及RHEL7.2 root密码破解、RHEL6.5安装vmware tools
1.Linux用户管理 Linux系统中,存在三种用户 A.超级用户:root 最高权限,至高无上 在windows中 administrator是可以登录的最高权限,但是,system权限最高,不能 ...
- nyoj38——最小生成树
布线问题 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 南阳理工学院要进行用电线路改造,现在校长要求设计师设计出一种布线方式,该布线方式需要满足以下条件:1.把所有 ...
- Mac安装MySQLdb遇到的坑
最近项目移植, 再进行virtualenv环境安装的时候遇到mysql-python死活安装失败 首先是这个错误: sh: /usr/local/bin/mysql_config: No such f ...
- 双系统下ubuntu不能访问658GB卷,磁盘挂载失败。
win10+ubuntu双系统出现以下错误: Error mounting /dev/sda5 at /media/captain/AC8CF85B8CF8218E: Command-line `mo ...
- [转载]java获取word里面的文本
需求场景 开发的web办公系统如果需要处理大量的Word文档(比如有成千上万个文档),用户一定提出查找包含某些关键字的文档的需求,这就要求能够读取 word 中的文字内容,而忽略其中的文字样式.表格. ...