http://codeforces.com/contest/349/problem/B

贪心

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf=<<; int a[];
int v,k;
int main()
{
while(scanf("%d",&v)!=EOF)
{
int min1=inf;
k=;
for(int i=; i<=; i++)
{
scanf("%d",&a[i]);
if(a[i]<min1)
{
min1=a[i];
k=i;
}
else if(a[i]==min1&&k<i)
{
k=i;
}
}
if(v<min1)
{
printf("-1\n");
continue;
}
if(v%min1==)
{
int m=v/min1;
for(int i=; i<=m; i++)
{
printf("%d",k);
}
printf("\n");
}
else
{
int len=v/min1;
for(int j=len; j>=; j--)
{
for(int i=; i>=; i--)
{
int x=v-a[i];
if(x<) continue;
if(x/min1==j-)
{
printf("%d",i);
v-=a[i];
break;
}
}
}
printf("\n");
}
}
return ;
}

cf B. Color the Fence的更多相关文章

  1. ACM Color the fence

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

  2. codeforces 349B Color the Fence 贪心,思维

    1.codeforces 349B    Color the Fence 2.链接:http://codeforces.com/problemset/problem/349/B 3.总结: 刷栅栏.1 ...

  3. NYOJ-791 Color the fence (贪心)

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

  4. 349B - Color the Fence

    Color the Fence Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  5. nyoj Color the fence

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

  6. Codeforces 349B - Color the Fence

    349B - Color the Fence 贪心 代码: #include<iostream> #include<algorithm> #include<cstdio& ...

  7. nyoj 791——Color the fence——————【贪心】

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

  8. Codeforces D. Color the Fence(贪心)

    题目描述: D. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  9. CF 484E - Sign on Fence

    E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

随机推荐

  1. hdu Examining the Rooms

    这道题的知识点第一次听说 ,就是应用斯特林数.题目的意思是给你房间数N,和最多能破门的个数,让你求能全部把房间打开的概率! a[i][j]=a[i-1][j-1]+(i-1)*a[i-1][j]; # ...

  2. CPU卡读写程序

    CPU卡也称智能卡,卡内的集成电路中带有微处理器CPU.存储单元(包括随机存储器RAM.程序存储器ROM以及芯片操作系统COS.装有COS的CPU卡相当于一台微型计算机,不仅具有数据存储功能,同时具有 ...

  3. 如何给开源的DUILib支持Accessibility(论述了DUILib的六个缺点,很精彩)

    最近的工作是给开源的DUILib支持Accessibility, 一些经验记录并分享下.   微软的Accessibility其实Windows平台上一个挺重要的东西, 尽管在国内不受重视,但是如果你 ...

  4. windows下重命名一个带有前缀"."dot字符的名字的错误问题

    如果用正常的右键重命名那么肯定会报错的,比如: 有一个名为project的文件,我想把它命名为.project,加了个前缀dot.然后window就报错了,弹出个对话框让“你必须输入一个文件名”.它可 ...

  5. 初识Mybatis框架,实现增删改查等操作

    此第一次接触Mybatis框架确实是有点不适应,特别是刚从Hibernate框架转转型过来,那么为什么要使用Mybatis框架,Mybatis框架和Hibernate框架又有什么异同呢? 这个问题在我 ...

  6. Thread的run()与start()的区别

    Java的线程是通过java.lang.Thread类来实现的.VM启动时会有一个由主方法所定义的线程.可以通过创建Thread的实例来创建新的线程.每个线程都是通过某个特定Thread对象所对应的方 ...

  7. 【转】解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题

    原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点Li ...

  8. openstack组件手动部署整合

    preface:当你完全且正确的配置好整个OpenStack ENV 你将能看到的和体验到的!!! 我们先来看看简单效果吧,祝君能在这条路上走的更远,更好;

  9. Maven--生命周期和插件(四)

    <Maven--搭建开发环境(一)> <Maven--构建企业级仓库(二)> <Maven—几个需要补充的问题(三)> <Maven—生命周期和插件(四)&g ...

  10. PyInstaller打包Python脚本为exe

    1.PyInstaller-3.1.1  百度云链接  http://pan.baidu.com/s/1jHYWin8 密码  oapl 2.安装最新版本的 pywin32-217.win32-py2 ...