题目:Petya and Inequiations
传送门:

http://codeforces.com/problemset/problem/111/A

http://codeforces.com/problemset/problem/112/C

分析:
  先引一个简单的结论:“(a+b)^2>=a^2+b^2”,可得一个简单的贪心:让其中一个数越大越好;再从“a[1] + a[2] + ... + a[n] <= y”入手:让a[1]越大越好,a[2]、a[3]...a[n]都为1;如果这种构造方法不行,则无解。
代码:

#include<cstdio>
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
long long n,x,y;
scanf("%I64d%I64d%I64d\n",&n,&x,&y);
if(y<n || (y-n+)*(y-n+)+(n-)<x)
printf("-1\n");
else{
printf("%d\n",y-n+);
for(int i();i<=n;++i)printf("1\n");
}
//fclose(stdin);fclose(stdout);
return ;
}

codeforces 111A/112C Petya and Inequiations的更多相关文章

  1. Codeforces Beta Round #85 (Div. 1 Only) A. Petya and Inequiations 贪心

    A. Petya and Inequiations Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  2. codeforces 111C/112E Petya and Spiders

    题目: Petya and Spiders传送门: http://codeforces.com/problemset/problem/111/C http://codeforces.com/probl ...

  3. codeforces 111B/112D Petya and Divisors

    题目:Petya and Divisors传送门: http://codeforces.com/problemset/problem/111/B http://codeforces.com/probl ...

  4. 【Codeforces 111C】Petya and Spiders

    Codeforces 111 C 题意:给\(n\times m\)的网格,每个点上有一个蜘蛛,每个蜘蛛可以向上.下.左.右走一步或者不动,问最多能存在多少没有蜘蛛的点. 思路1: 首先因为\(n\) ...

  5. Codeforces 1082 G - Petya and Graph

    G - Petya and Graph 思路: 最大权闭合子图 对于每条边,如果它选了,那么它连的的两个点也要选 边权为正,点权为负,那么就是求最大权闭合子图 代码: #pragma GCC opti ...

  6. CF刷题-Codeforces Round #481-G. Petya's Exams

    题目链接:https://codeforces.com/contest/978/problem/G 题目大意:n天m门考试,每门考试给定三个条件,分别为:1.可以开始复习的日期.2.考试日期.3.必须 ...

  7. Codeforces 832 B. Petya and Exam-字符串匹配

    补的若干年以前的题目,水题,太菜啦_(:з」∠)_    B. Petya and Exam   time limit per test 2 seconds memory limit per test ...

  8. 【Codeforces 1042D】Petya and Array

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 把a[i]处理成前缀和 离散化. 枚举i从1..n假设a[i]是区间和的a[r] 显然我们需要找到a[r]-a[l]<t的l的个数 即a ...

  9. CodeForces 1082 G Petya and Graph 最大权闭合子图。

    题目传送门 题意:现在有一个图,选择一条边,会把边的2个顶点也选起来,最后会的到一个边的集合 和一个点的集合 , 求边的集合 - 点的集合最大是多少. 题解:裸的最大权闭合子图. 代码: #inclu ...

随机推荐

  1. 彻底理解 Linux 的搜索工具: grep 和 awk

    grep 官方手册 awk 官方手册, awk 学习资料 1. grep grep 用于打印匹配指定模式的行. 1.1 介绍 grep 命令从输入文件中查找匹配到给定模式列表的行.发现匹配到的行后,默 ...

  2. linux使用pigz多线程压缩

    因为tar zip是单线程的压缩,压缩起来很慢,这个使用使用pigz工具辅助就会使用多线程了. 安装 sudo apt install pigz 压缩 tar cvf - test.txt | pig ...

  3. vue分页练习

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 移动端安全 - 安卓Android - 工具相关

    渗透工具 drozer .安装文件解压后文件介绍 setup.exe ---安装 agent.apk ---用于调试 - 安装在安卓手机上 使用命令 . cd 到 drozer 安装目录 . adb ...

  5. apt-get updete以及apt-get upgrade的区别

    You should first run update, then upgrade. Neither of them automatically runs the other. apt-get upd ...

  6. P3914染色计数

    题目描述 有一颗\(N\)个节点的树,节点用\(1,2,\cdots,N\)编号.你要给它染色,使得相邻节点的颜色不同.有\(M\)种颜色,用\(1,2,\cdots,M\)编号.每个节点可以染\(M ...

  7. asp.net ajax的使用

    参考:https://www.cnblogs.com/acles/articles/2385648.html https://www.cnblogs.com/xujingyang/p/5560646. ...

  8. 【学习总结】GirlsInAI ML-diary day-21-初识 Numpy, Matplotlib, Seanborn [柱状图、折线图、箱图]

    [学习总结]GirlsInAI ML-diary 总 原博github链接-day21 初识 Numpy, Matplotlib, Seanborn [柱状图.折线图.箱图] 一.Titanic练习赛 ...

  9. elasticsearch 基础 —— ReIndex

    Reindex会将一个索引的数据复制到另一个已存在的索引,但是并不会复制原索引的mapping(映射).shard(分片).replicas(副本)等配置信息. 一.reindex的常用操作 1.re ...

  10. pycharm 断点跟踪

    F8 下一步 F7 step info F9 直接运行