codeforces 810A Straight <<A>> 暴力
来源:互联网 发布:midi 入门 软件 编辑:程序博客网 时间:2024/06/14 09:50
题意:给定n和k,并且已知一个数组a,a.size=n。求最少加几个小于等于k的数,使得平均值四舍五入后等于k。
思路:每次加个k是最划得来的,假设加x个数ai....a(i+x) <k 那么(ai+...ai+x)/(n+x)<kx/(n+x),直接枚举x。
#include<cstdio>#define ll long longusing namespace std;int main(){int n,k;while(~scanf("%d%d",&n,&k)){ll sum=0;int a;for(int i=0;i<n;i++){scanf("%d",&a);sum+=a;}int ans=0;for(int x=0;;x++){int temp=(int)(0.5+(double)(sum+k*x)/(x+n));if(temp>=k){ans=x;break;}}printf("%d\n",ans);}}
阅读全文
0 0
- codeforces 810A Straight <<A>> 暴力
- CodeForces 810A Straight <<A>> 【数学】【模拟】
- codeforces 810A Straight «A»
- Codeforces 810A Straight «A» 题解
- Codeforces Round #415 (Div. 2)A. Straight «A» (暴力)
- Codeforces Round #415 A Straight <<A>>
- 【Codeforces 808 A. Straight «A»】
- CodeForces 13A【暴力】
- CodeFroces 810A Straight «A»
- 810A. Straight «A»
- codeforces——810A——Straight «A»
- CodeForces 810A——Straight «A» ——二分
- Codeforces Round #415 (Div. 2) A. Straight «A»
- Codeforces Round #415 (Div. 2) A. Straight «A»
- Codeforces 485 A. Factory 暴力
- Codeforces 398A Cards 暴力
- codeforces 577A(暴力枚举)
- CodeForces 156A Message(暴力)
- poi读取excel
- ajax的简单实例 XMLHttpRequest对象
- 05-树8 File Transfer (25分)---并查集
- 分布式集群高并发问题
- File类及其方法
- codeforces 810A Straight <<A>> 暴力
- jsp的表单数据提交,中文出现乱码的处理
- 使用BOM通常可实现如下功能、window对象常用的属性、方法、事件
- 洛谷 P1064 金明的预算方案
- java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203)
- (poj 1088 滑雪) <记忆化搜索>
- 2017.05.20【usaco2017_Mar Gold & Silver】B组
- 把Matlab的p代码还原为可读的m代码的可能性
- 图像处理基础知识系列之一:边界跟踪之内边界跟踪算法解释