http://poj.org/problem?id=1416

 #include<cstdio>
#include<cstring>
#define MAXN 100
using namespace std; int c,m;
int ans[MAXN],t[MAXN];
int max,r;
int ansk; void dfs(int n,int sum,int now,int k,int p)
{
if(n==)
{
t[k]=now;
if(sum+now>m) return;
if(sum+now==max) r++;
else if(sum+now>max)
{
max=sum+now;
r=;
ansk=k;
for(int i=; i<=k; i++) ans[i]=t[i];
}
return ;
}
int mm=n%;
dfs(n/,sum,now+p*mm,k,p*);
t[k]=now;
dfs(n/,sum+now,mm,k+,);
}
int main()
{
while(scanf("%d%d",&m,&c)&&c&&m)
{
max=,r=;
dfs(c/,,c%,,);
if(max==)
{
printf("error\n");
continue;
}
if(r>) {printf("rejected\n");continue;}
printf("%d",max);
for(int i=ansk; i>=; i--)
printf(" %d",ans[i]);
printf("\n");
}
return ;
}

pojShredding Company的更多相关文章

  1. Elasticsearch索引(company)_Centos下CURL增删改

    目录 返回目录:http://www.cnblogs.com/hanyinglong/p/5464604.html 1.Elasticsearch索引说明 a. 通过上面几篇博客已经将Elastics ...

  2. Microsoft Dynamics AX 2012: How to get Company,Customer and Vendor address in AX 2012

    Scenario:  “How to get Addresses of “Customer, Vendor and Company” 1)      First we need to identify ...

  3. poj1416 Shredding Company

    Shredding Company Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5379   Accepted: 3023 ...

  4. CodeForces 125E MST Company

    E. MST Company time limit per test 8 seconds memory limit per test 256 megabytes input standard inpu ...

  5. CF 321B Kefa and Company(贪心)

    题目链接: 传送门 Kefa and Company time limit per test:2 second     memory limit per test:256 megabytes Desc ...

  6. 搜索+剪枝 POJ 1416 Shredding Company

    POJ 1416 Shredding Company Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5231   Accep ...

  7. 二分+动态规划 POJ 1973 Software Company

    Software Company Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1112   Accepted: 482 D ...

  8. 【Moqui业务逻辑翻译系列】Story of Online Retail Company 在线零售公司的故事

    h1. Story of Online Retail Company 在线零售公司的故事 Someone decides to sell a product. [Product Marketer Ma ...

  9. Codeforces 556D Restructuring Company

    传送门 D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. python list排序的两种方法及实例讲解

    对List进行排序,Python提供了两个方法方法1 用List的内建函数list sort进行排序list sort(func=None, key=None, reverse=False)Pytho ...

  2. js~this的陷阱

    在JS中,当前对象一般用this表示,在jquery中,当前的对象是用$(this)表示,这些都是最基础的知识,没什么可说的,但我要说的是,当this出现在某个深度时,它的含义你自己要清楚,它是指离当 ...

  3. Angular2学习

    1.新建项目 2.新建Model public class TodoItem { public int Id { get; set; } public string Key { get; set; } ...

  4. PhoneGap应用开发的那些坑爹事儿

    子曾经曰过:如果你恨一个人,让他去开发PhoneGap应用:如果你爱一个人,让他去开发PhoneGap应用. 去年这个时候我很烦恼,因为我觉得我OUT了. 起因是我买了一台Android系统的手机.当 ...

  5. Android获取cpu和内存信息、网址的代码

      android获取手机cpu并判断是单核还是多核 /** * Gets the number of cores available in this device, across all proce ...

  6. MaxReceivedMessageSize :已超过传入消息(65536)的最大消息大小配额

    做的windows应用程序(后台调用webservice),数据量大的时候,报错如下: System.ServiceModel.CommunicationException: 已超过传入消息(6553 ...

  7. 刨根问底:对于 self = [super init] 的思考

    对象初始化有两种方式:[class new] 与 [[class alloc] init] 对于后者,有分配和初始化的过程,alloc 从应用程序的虚拟地址空间上为该对象分配足够的内存,并且将新对象的 ...

  8. Tab页签切换

    js之tab页签切换效果       现在web网站,很多地都需要用到tab页签. 示例:         $(document).ready(function(){               va ...

  9. gulp初涉

    1.什么是gulp? gulp是前端开发过程中一种基于流的代码构建工具,是自动化项目的构建利器:它不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成:使用它,不仅可以很 ...

  10. jQuery 表单验证插件——Validation(基础)

    这个插件不错,是用jquery写的.能进行表单验证.我喜欢它的原因是因为 1.他有自带的验证规则 2.你可以自己写验证规则 3.可以通过ajax与后台交互,与后台数据比较.最后返回结果!我在表单中要验 ...