http://codeforces.com/contest/339/problem/C

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int dp[][][];
char str[];
int f[];
int m;
void dfs(int i,int j,int k)
{
if(i==) return ;
dfs(i-,k-j,dp[i][j][k]);
printf("%d ",k);
} int main()
{
scanf("%s",str);
int cnt=;
for(int i=; i<; i++)
{
if(str[i]=='')
{
f[++cnt]=i+;
}
}
scanf("%d",&m);
memset(dp,-,sizeof(dp));
dp[][][]=;
for(int i=; i<=m; i++)
{
for(int j=; j<=; j++)
{
for(int k=; k<=; k++)
{
if(dp[i-][j][k]!=-)
{
for(int c=; c<=cnt; c++)
{
if(f[c]>j&&f[c]!=k)
dp[i][f[c]-j][f[c]]=k;
}
}
}
}
}
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
if(dp[m][i][j]!=-)
{
printf("YES\n");
dfs(m,i,j);
return ;
}
}
}
printf("NO\n");
return ;
}

cf C. Xenia and Weights的更多相关文章

  1. [codeforces 339]C. Xenia and Weights

    [codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...

  2. Xenia and Weights(深度优先搜索)

    Xenia and Weights time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  3. codeforces 339C Xenia and Weights(dp或暴搜)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Weights Xenia has a set of weig ...

  4. CF #635D Xenia and Colorful Gems 枚举+二分

    Xenia and Colorful Gems 题意 给出三个数组,在每个数组中选择一个数字x,y,z,,使得\((x-y)^2+(y-z)^2+(x-z)^2\)最小. 思路 我们假设x<=y ...

  5. CF A. Xenia and Divisors

    题目大意: n(为三的倍数)个数的一个序列(每个数均不大于7),找出a,b,c a能被b整除,b能被c整除,序列中的每个数都被用到. 1 2 3 4 5 6 7 只有 1 2 4 1 2 6 1 3 ...

  6. cf D. Xenia and Hamming

    http://codeforces.com/contest/357/problem/D 题意:给你两个数n和m,表示两个字符串的循环次数,然后给出两个字符串,求出其相同位置字符不同的个数. 先求出两个 ...

  7. CodeForces 339C Xenia and Weights(暴力求解DFS)

    题意:给定 1-10的某几种砝码,给定的每种有无穷多个,然后放 m 个在天平上,要满足,相邻的两次放的砝码不能是同一种,然后是在天平两端轮流放,并且放在哪一个托盘上,那么天平必须是往哪边偏. 析:这个 ...

  8. 【Codeforces 339C】Xenia and Weights

    [链接] 我是链接,点我呀:) [题意] 在天平上放砝码 你要在左边放一下然后到右边放一下 一直重复这样放m次 每次你放在其中一边都要让另外一边的重量比你少 你可以用1~10中的某些砝码 问你要怎样放 ...

  9. Xenia and Weights(Codeforces Round #197 (Div. 2)+DP)

    题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #includ ...

随机推荐

  1. QQ截图时窗口自动识别的原理(WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx,RealChildWindowFromPoint)

    新版的QQ在截图时加入了窗口自动识别的功能,能根据鼠标的位置自动画出下面窗口的轮廓.今天有人在论坛上问起这个问题,下面我们来探讨这个功能的实现原理. 首先我们要明白截图软件的基本原理,截图时实际上是新 ...

  2. QuickReport多页打印

    You use composite reports for this(TQrCompositeReport) on the quickreports tabTake a look in the Dem ...

  3. MVC3路由设置访问后缀 html jsp

     C# Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546   publ ...

  4. 《iPhone高级编程—使用Mono Touch和.NET/C#》

    第1章 C#开发人员基于MonoTouch进行iPhone开发概述 1 1.1 产品对比 2 1.1.1 .NET Framework 2 1.1.2 Mono 2 1.1.3 MonoTouch 3 ...

  5. python编程之字符串转处理

    比如255的16进制是FF. 转换成整型就是  int("FF",16)   console上输出就是255   int("FFFF",16)就是65535 如 ...

  6. STLtoSVG,and SVG to Bmp

    先用这两个工具: Slic3R或者Skeinforge:这个两个工具的作用就是把STL文件切片为叠加的矢量图(SVG格式) 因为SVG是分层的,一层一层的把每层都转换成一张Bmp文件 听说ImageM ...

  7. eclipse,tomcat部署web项目,以及本地文件访问

    1.直接把项目复制到Tomcat安装目录的webapps目录中,这是最简单的一种Tomcat项目部署的方法,也是初学者最常用的方法. 2.在tomcat安装目录中有一个conf文件夹,打开此文件夹,其 ...

  8. c语言const

    const关键字 const和指针结合,共有4种形式 const int *p; p是一个指针,指针指向一个int型数据.p所指向的是个常量. int const *p; p是一个指针,指针指向一个i ...

  9. 使用教程 - BestSync同步软件 - SQL2008R2 数据库定时备份解决方案

    需求: 1.      某公司的管理软件,数据库为SQL2008R2.2.      将整个数据库作为一个文件,定时同步到FTP 服务器3.      需要有多个备份,每同步一次,都备份上次的文件到备 ...

  10. hdu 1695 GCD(欧拉函数+容斥)

    Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD( ...