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. android特效

    http://houxiyang.com/archives/89/ http://blog.csdn.net/hjj0212/article/details/8535817 http://www.li ...

  2. flex

    http://www.w3.org/html/ig/zh/wiki/Css3-flexbox https://developer.mozilla.org/zh-CN/docs/CSS/CSS_Refe ...

  3. LeetCode_Generate Parentheses

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  4. USART笔记 基于STM32F107VCT6

    USART   通用同步异步收发器 通用同步异步收发器(USART)提供了一种灵活的方法与使用工业标准NRZ异步串行数据格式的外部设备之间进行全双工数据交换.USART利用分数波特率发生器提供宽范围的 ...

  5. Qt浅谈之四十九俄罗斯方块(代码来自网络)

    一.简介 从网上下载了一个Qt实现的俄罗斯方块单机版的源码,觉得非常有意思,故以博客形式记录下来,以便慢慢来研究.在centos6.6下编译运行(注意程序运行需要读取pro目录的配置文件,若把编译目录 ...

  6. JS打印、预览(IE,Chrome)

    IE下: 调用IE内置打印组件完成web打印方案.IE调用ActiveX实现打印. 重点: 注意: 1.CSS对打印的控制: .Noprint{display:none;} .PageNext{pag ...

  7. library cache: mutex X

    我们先来看看 library cache: mutex X . 是个什么东西 The library cache mutex is acquired for similar purposes that ...

  8. 【转】ubuntu中的Wine详解

    原文网址:http://blog.csdn.net/iwtwiioi/article/details/10530561 什么是wine?(转自百度百科,具体看百科) wine,是一款优秀的Linux系 ...

  9. Linux开发工具的使用

    1.   Linux开发工具的使用 Vim编译的使用 Gdb调试工具的使用 Makefile的编写 linux跟踪调试 SSH的使用 subversion的使用 1.   Linux开发工具的使用 V ...

  10. hdu2769:枚举+同余方程

    题意:有一个随机数生成器  x[i+1]=(a*x[i]+b)%10001 已知  x1,x3,x5...求 x2,x4,x6...... x的个数为 2n (n<=10000) a,b也在 0 ...