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字符串连接的5种方法

    总结了一下Python字符串连接的5种方法: 加号 第一种,有编程经验的人,估计都知道很多语言里面是用加号连接两个字符串,Python里面也是如此直接用 "+" 来连接两个字符串: ...

  2. EF 5.0 和 EF4.0 语法区别

    // 实现对数据库的添加功能,添加实现EF框架的引用 40 41 public T AddEntity(T entity) 42 43 { 44 45 //EF4.0的写法 添加实体 46 47 // ...

  3. GDataXML的配置和使用

    1.下载链接:http://code.google.com/p/gdata-objectivec-client/downloads/list下载“gdata-objective-c client li ...

  4. 【教训】rm -fr ./* 教训

    昨晚犯了一个重大错误,运行了 rm -rf ./* 本来是要删除一个不重要的目录的,结果在它的父目录下运行了上面命令,结果...都没了... 幸好数据库文件没有被删掉,数据还在,网站程序被删掉了,不久 ...

  5. codevs愚蠢的矿工(树形DP)

    /* 树形DP 根节点一定有人 然后 剩下的人没到每个孩子去 因为孩子数可能很多 不好枚举 所以转二叉树 分两部分 O(sum)就可以了 当然 转二叉树候必须顾及原来树的一些性质 如不能只选左孩子 转 ...

  6. 1、第1课.net学习2150916

    HTML标签 1.<p> <p> 标签 段落标签 2.<h1-6></h1> 文字标签从1-6 3. <i></i> 斜体 &l ...

  7. entity 实体模型timeout设置

    public Entities(): base("name=Entities") { var adapter = (IObjectContextAdapter)this; var ...

  8. php创建读取 word.doc文档

    创建文档; <?php $html = "this is question"; for($i=1;$i<=3;$i++){ $word = new word(); $w ...

  9. 学习JAVA第一部分总结

    把自己这几天的学习情况记录下来. 第一章,认识JAVA,了解JAVA的运行机制,虚拟机. 第二章,了解java的注释,标识符,关键字.. 第三章,基本的数据类型,byte short int long ...

  10. 运行phpize时出现:Cannot find autoconf. Please check your autoconf installation

    运行/usr/local/webserver/php/bin/phpize时出现:Configuring for:PHP Api Version: 20041225Zend Module Api No ...