【Codeforces 1073D】Berland Fair
【链接】  我是链接,点我呀:) 
 【题意】
题意
【题解】
我们可以从左到右枚举一轮。
定义一个cost表示这一轮花费的钱数
如果cost+a[i]beforeT
cost>beforeT/(1+x)
x*cost>x*beforeT/(1+x)
x*cost>beforeT/(1/x+1)
x>=1
显然x越大,右边越来越大
则x*cost>beforeT/2
则newT
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
const long long M = 15e6;
int n;
ll T,ans = 0;
int a[N+10];
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> T;
    for (int i = 1;i <= n;i++) cin >> a[i];
    while (1){
        ll sum = 0;
        int cnt = 0;
        for (int i = 1;i <= n;i++){
            if (sum+a[i]>T){
                continue;
            }else{
                cnt++;
                sum = sum + a[i];
            }
        }
        if (cnt==0) break;
        ans = ans + T/sum*cnt;
        T = T%sum;
    }
    cout<<ans<<endl;
	return 0;
}
【Codeforces 1073D】Berland Fair的更多相关文章
- 【Codeforces 1083A】The Fair Nut and the Best Path
		[链接] 我是链接,点我呀:) [题意] 题意 [题解] 我们最后要的是一条最长的路径. 这条路径的权值和是所有点的权值和-所有边的权值和且这个值最大. 显然如果我们在某一条边上的累计的权值和< ... 
- Codeforces 1073D:Berland Fair(模拟)
		time limit per test: 2 secondsmemory limit per test: 256 megabytesinput: standard inputoutput: stand ... 
- 【codeforces 415D】Mashmokh and ACM(普通dp)
		[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ... 
- 【55.70%】【codeforces 557A】Ilya and Diplomas
		time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ... 
- 【codeforces 758A】Holiday Of Equality
		time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ... 
- 【16.23%】【codeforces 586C】Gennady the Dentist
		time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ... 
- 【codeforces 762B】USB vs. PS/2
		time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ... 
- 【30.43%】【codeforces 746C】Tram
		time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ... 
- 【58.33%】【codeforces 747B】Mammoth's Genome Decoding
		time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ... 
随机推荐
- Unity ScriptObject
			http://godstamps.blogspot.com/2012/02/unity-3d-scriptableobject-assetbundle.html http://ivanozanchet ... 
- 数据结构之顺序队列(C实现)
			一.队列是什么 队列是一种可以实现“先进先出”的存储结构. 队列通常可以分为两种类型: 一.顺序队列,采用顺序存储,当长度确定时使用. 顺序队列又有两种情况: ①使用数组存储队列的称为静态顺序队列. ... 
- Linux学习之路2 Bash的基本操作
			一.SHELL的介绍 shell分为两种:CLI(command Line Interface)和GUI(Graphical User Interface) 操作系统中的shell: GUI:GNOM ... 
- C语言学习(1)-环境配置
			写在前面的话,该文章是看杨老师的一套视频,所做的一些笔记,边看边写,再此谢谢杨老师. 1.学习C之前需要避免的误区 误区一:C++是C的升级版:C#是C++的升级版 误区二:C/C++就是Visual ... 
- JavaScript(十一)Dom
			Dom(Document object module) 1.获取dom对象的方法 正常用的方法 推荐 getElementById()//通过id选择唯一的dom getElementsByClass ... 
- 在Redux中使用插件createAction之后
			我们知道在React的Redux的中的action在项目开发过程中,一般时使用createAction来生成 举个栗子,小李子: const createTodo=createACtion('CREA ... 
- iOS从手机相册选择一张照片并显示 Objective-C
			要先给app设置访问相册的权限: 在项目的Info.plist文件里添加Privacy - Photo Library Usage Description权限 ViewController.h: #i ... 
- Angular——自定义服务
			基本介绍 之前我们介绍了angular内置的几种服务,这里我们介绍如何自己定义自己的服务,主要是通过三个方法:factory.service.value 基本使用 factory:可以返回对象,也可以 ... 
- cookie、json详解
			什么是cookie 1.cookie是存储于访问者计算机中的变量2.cookie是浏览器提供的一种机制3.可以由js控制(设置.读取.删除)4.cookie可以实现跨页面全局变量可以跨越同域名下多个网 ... 
- 前端零基础快速入门JavaScript
			JavaScript代码可以直接嵌在网页的任何地方,不过通常我们都把JavaScript代码放到<head>中: <html><head> <script&g ... 
