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. setState的同步更新

    react中的setState特点: 是异步操作函数: 组件在还没有渲染之前, this.setState 还没有被调用: 批量执行 State 转变时让 DOM 渲染更快(相对比一个一个的setSt ...

  2. .gitignore模板

    github/gitignore · GitHub列举了一些有用的.gitignore的模板.比如这个是visual studio的. 另外说一个题外话,如果不想看见solution目录的那个sdf, ...

  3. Android 更新UI的两个方法

    Android 更新UI的两个方法 在Android的开发过程中,常常需要适时的更新UI.Androd中的UI是在主线程中更新的.如果在主线程之外的线程中直接更新,就会出现报错并抛出异常: andro ...

  4. Linux下生产者与消费者的线程实现

    代码见<现代操作系统> 第3版. 为了显示效果,添加了printf()函数来显示运行效果 #include<stdio.h> #include<pthread.h> ...

  5. 如何在myeclipse8.5中使用maven

    今天搞了一天才搞清楚这个问题,一直导入不了mavendependencies,后来发现是 13-11-23 下午06时47分11秒: Downloading http://mirrors.ibibli ...

  6. Linux的进程优先级-邹立巍

    http://liwei.life/2016/04/07/linux%E7%9A%84%E8%BF%9B%E7%A8%8B%E4%BC%98%E5%85%88%E7%BA%A7/

  7. [转] Are You Making a Big Mistake in This Volatile Market?

    Stock market volatility continues unabated. It may be too early to tell, but I’m marking the top of ...

  8. HDU5303

    题意:给定一个环形道路长度为L,以及环形道路下标为0处为起始点,在环形道路上距离起始点Xi位置种植一颗苹果树,该树有a个苹果,篮子的最大容量为K,那么求摘完全部苹果所需的最短距离. 思路:之前没想出来 ...

  9. 开发solr功能问题点

    Criteria criteria = new Criteria(); public Criteria and(Criteria criteria) { this.criteriaChain.add( ...

  10. 开发RESTful WebService

    RESTful风格的webservice越来越流行了,sun也推出了RESTful WebService的官方规范:JAX-RS,全称:Java API for RESTful WebService. ...