nyoj791color the fence
来源:互联网 发布:汉服推荐 知乎 编辑:程序博客网 时间:2024/06/07 02:06
#include<stdio.h>
int main()
{
int n,a[10];
while(scanf("%d",&n) != EOF)
{
int i,min = 0x3f3f3f3f,j;
for(i = 1;i <= 9;i++ )
{
scanf("%d",&a[i]);
if(min > a[i]) min = a[i];
}
if(n < min) printf("-1\n");
else
{
for(i = n/min-1;i >= 0;i--)
{
for(j = 9;j > 0;j--)
{
if(a[j] <= n && (n-a[j])/min >= i)
{
printf("%d",j);
n -= a[j];
break;
}
}
}
printf("\n");
}
}
return 0;
int main()
{
int n,a[10];
while(scanf("%d",&n) != EOF)
{
int i,min = 0x3f3f3f3f,j;
for(i = 1;i <= 9;i++ )
{
scanf("%d",&a[i]);
if(min > a[i]) min = a[i];
}
if(n < min) printf("-1\n");
else
{
for(i = n/min-1;i >= 0;i--)
{
for(j = 9;j > 0;j--)
{
if(a[j] <= n && (n-a[j])/min >= i)
{
printf("%d",j);
n -= a[j];
break;
}
}
}
printf("\n");
}
}
return 0;
}
这个题真的是好题,看了好久才看懂。
0 0
- nyoj791color the fence
- 墙头草 on the fence
- acm-Color the fence
- 791 Color the fence
- nyoj color the fence
- Color the fence
- Color the fence
- Color the fence
- Color the fence
- NYOJ-Color the fence
- Color the fence
- CF349B Color the fence-20140208
- NYOJ-791 Color the fence
- NYOJ 791 Color the fence
- nyoj 791 Color the fence
- H - Color the Fence -贪心
- NYOJ791 Color the fence(贪心)
- NYOJ 791 Color the fence
- 架构设计三部曲之如何写架构设计说明书
- Matlab中的PDEPE求解"瞬态型"或"发展型"非线性偏微分方程组
- Hdu 2044 一只小蜜蜂 简单DP
- Java theory and practice: More flexible, scalable locking in JDK 5.0
- 第十一章编程练习(5)
- nyoj791color the fence
- openssh
- 接口举例
- Druid是什么和用StatViewServlet用于展示Druid的统计信息
- Hdu2647【拓扑排序】
- Java—进程间通讯的有几种方法
- 什么是Modernizr?
- Hdu 2041 超级楼梯 简单DP
- 2016蓝桥杯算法训练——大小写转换