P4747 D’s problem(d)
背景
冬令营入学测试题
描述
题目描述
小D是一名魔法师,它最喜欢干的事就是对批判记者了。
这次记者招待会上,记者对于小D的数学很好奇。于是小D找了个方法把记者批判了一番。
它对记者抛出了这么一个问题:我有n点能量,写下数字i(1<=i<=9)需要花费a{i}点能量,我用这n点能量最多能写出什么数来?(当然可以不用光n点能量,具体看样例)
记者们一脸懵逼,于是来求助于你。
输入格式
一行10个数,表示n,a1,a2,a3,…,a9。
输出格式
一个数表示答案。
备注
输入样例1
10 2 2 1 2 2 2 2 2 2
输出样例1
3333333333
输入样例2
10 4 11 11 11 11 11 11 11 10
输出样例2
11
数据范围
对于30%的数据n,ai<=10。
对于60%的数据n,ai<=100。
对于100% 的数据1<=n,ai<=1000000,n>=min{ai}。
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; const int INF=0x7fffffff; int n,t,minn=INF;
int ans[],a[]; int main()
{
scanf("%d",&n);
for(int i=;i<;i++)
{
scanf("%d",&a[i]);
if((a[i]<minn)||(a[i]==minn&&i>t))
{
minn=a[i];
t=i;
}
}
ans[t]=n/minn;
n%=minn;
for(int i=;i>t;i--)
{
while(n+minn>=a[i])
{
ans[t]--;
ans[i]++;
n=n+minn-a[i];
}
}
for(int i=;i>=;i--)
for(int j=;j<=ans[i];j++)
printf("%d",i);
return ;
}
P4747 D’s problem(d)的更多相关文章
- 清北学堂2017NOIP冬令营入学测试P4747 D’s problem(d)
时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试题 描述 题目描述 小D是一名魔法师,它最喜欢干的事就是对批判记者了. 这次记者招待会上,记者对 ...
- 清北学堂2017NOIP冬令营入学测试
P4744 A's problem(a) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试题,每三天结算一次成绩.参与享优惠 描述 这是一道有背 ...
- Tyvj2017清北冬令营入学测试
P4744 A's problem(a) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试题,每三天结算一次成绩.参与享优惠 描述 这是一道有背 ...
- 2016 年末 QBXT 入学测试
P4744 A’s problem(a) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试题,每三天结算一次成绩.参与享优惠 描述 这是一道有背 ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
随机推荐
- Codeforces Round #363 (Div. 2) B
Description You are given a description of a depot. It is a rectangular checkered field of n × m siz ...
- 关于强大的requests
存到文件: with open(filename, 'wb') as fd: for chunk in r.iter_content(chunk_size): fd.write(chunk) 使用 R ...
- Shell编程中的条件判断(条件测试)
Shell中的条件判断(测试)类型: 1) 整数测试 2) 字符测试 3) 文件测试 条件测试的表达式: (注: expression 与 [] 之间空格不能省略) [ expressi ...
- Hive 基本语法操练(五):Hive 的 JOIN 用法
Hive 的 JOIN 用法 hive只支持等连接,外连接,左半连接.hive不支持非相等的join条件(通过其他方式实现,如left outer join),因为它很难在map/reduce中实现这 ...
- 【JavaEE】Web Service 的工作原理
Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的 ...
- Maven基本使用汇总
1. 基础问题 0.eclipse工程转maven工程:工程->右键->configure->convert to maven project 1.pom.xml总是在项目的根目录. ...
- {ldelim},{rdelim} - smarty 内建函数
{ldelim}和{rdelim}用来转义模板的分隔符,缺省为{和}.你也可以用{literal}{/literal}来转义文本块(如Javascript或CSS). 例: {* 在模板外将原样打印分 ...
- 一、 Spring IOC 简介
一 . 什么是IOC(Inversion of Control) IOC :控制反转,也称为依赖注入(DI).听起来有点云里雾里,他到底是个啥,为什么Spirng中最基础的就是它? 我们的项目其实都是 ...
- ArcSDE空间数据库中SDE用户使用探讨 (转载)
ArcSDE作为空间数据库解决方案,应用非常广泛,本短文将尝试描述SDE的工作机制,简要说明空间数据库中SDE用户的使用方法.ArcSDE如何工作ArcSDE属于中间件技术,其本身并不能够存储空间数据 ...
- 报错:无法打开"cocos-ext.h" /添加第三方库
参考原文:http://lin-jianlong.diandian.com/post/2012-11-05/40042951271 1.项目属性->配置属性->C/C++->常规-& ...