题目: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. SPSS输出结果如何在word中设置小数点前面显示加0

    SPSS输出结果如何在word中设置小数点前面显示加0 在用统计分析软件做SPSS分析时,其输出的结果中,如果是小于1(绝对值)的数,那么会默认输出不带小数点的数值.例如0.362和 -0.141被显 ...

  2. Vagrant 构建 LNMP 一致环境

    GitHub 地址 <--- 所有文件都在这里 前提条件 安装 Vagrant,VirtualBox. 设置 下载软件并放入 soft 目录 MySQL:mysql-5.7.22-1.el7.x ...

  3. v-if指令

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

  4. 【ABAP系列】SAP ABAP基础-SQL的嵌套使用

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP基础-SQL的嵌 ...

  5. 编程语言-Python2-问题整理

    InsecureRequestWarning: Unverified HTTPS request is being made. import urllib3 urllib3.disable_warni ...

  6. python self和cls的区别

    1.self表示一个具体的实例本身.如果用了staticmethod,那么就可以无视这个self,将这个方法当成一个普通的函数使用. 2.cls表示这个类本身.

  7. 常见ORM框架及JDBC操作工具类

    在Java 程序里面去连接数据库,最原始的办法是使用JDBC 的API.我们先来回顾一下使用JDBC 的方式,我们是怎么操作数据库的. // 注册JDBC 驱动 Class.forName(" ...

  8. Yii2 错误 'Headers already sent.'

    错误日志如下: __source__: __topic__: web category: yii\web\HeadersAlreadySentException ip: level: message: ...

  9. NGUI的Tween动画的使用

    一,在创建Tween有,alpha,color,width,height,position,rotation,scale和transfrom这几种动画类型 1>alpha:颜色由浅变深(透明度) ...

  10. Android单位转换 (px、dp、sp之间的转换工具类)

    在Android开发中,涉及到屏幕视频问题的时候,px.dp.sp之间的转换比较重要的一部分,所以杨哥整理了一个工具类给大伙用. package com.zw.express.tool; import ...