【题目链接】:http://codeforces.com/contest/779/problem/B

【题意】



问你要删掉几个数字才能让原来的数字能够被10^k整除;

【题解】

/*
数字的长度不大;
让你删掉最小的数字个数
使得这个数字能被10^k整除;
搜索;
枚举哪些数字被删掉了;
bool记录;
最后再全部乘起来;
枚举删掉1个,删掉两个即可、3、4...;
注意前导0只能有一个的情况就好
*/

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 15; string s;
int po_w[12],k,len,di,num;
bool bo[15]; void dfs(int x, int now)
{
if (now >= num)
{
int nu = 0,t = 0,fir=-1;
rep1(i, 1, len)
if (bo[i])
{
if (fir == -1)
fir = s[i] - '0';
t++;
nu = nu * 10 + s[i] - '0';
}
if (fir == 0 && t > 1) return;
if (nu%di == 0)
{
printf("%d\n", num);
exit(0);
}
return;
}
if (x > len)
return;
bo[x] = false;
dfs(x + 1, now + 1);
bo[x] = true;
dfs(x + 1, now);
} int main()
{
//freopen("F:\\rush.txt", "r", stdin);
po_w[0] = 1;
rep1(i, 1, 9)
po_w[i] = po_w[i - 1] * 10;
cin >> s;
len = s.size();
s = ' ' + s;
scanf("%d", &k);
di = po_w[k];
memset(bo, true, sizeof bo);
for (num = 0;num <= len-1;num++)
dfs(1, 0);
return 0;
}

【codeforces 779B】Weird Rounding的更多相关文章

  1. 【codeforces 789D】Weird journey

    [题目链接]:http://codeforces.com/problemset/problem/789/D [题意] 给你n个点,m条边; 可能会有自环 问你有没有经过某两条边各一次,然后剩余m-2条 ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【51.27%】【codeforces 604A】Uncowed Forces

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【codeforces 604D】Moodular Arithmetic

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【27.40%】【codeforces 599D】Spongebob and Squares

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  7. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  8. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  9. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

随机推荐

  1. 【习题 6-7 UVA - 804】Petri Net Simulation

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟就好 [代码] /* 1.Shoud it use long long ? 2.Have you ever test sever ...

  2. zeromq and jzmq

    install c test install jzmq java test Storm UI Cluster Summary Version Nimbus uptime Supervisors Use ...

  3. [D3] Add hovercard

    The way to add hovercard is Append a div with class 'hovercard' in the tick function, positioning th ...

  4. Oracle动态SQL语句

    动态SQL返回游标: create or replace procedure proc_ValidityDueQuery( p_regioncode in number, p_pscode in nu ...

  5. cocos2dx--vs2012+lua开发环境搭建

    cocos2dx版本号:cocos2dx2.2.3 lua插件:babelua 1.5.3  下载地址:http://pan.baidu.com/s/1i3mPD8h 第一步:先关闭vs,双击下载下来 ...

  6. Linux CentOS PhpMyAdmin安装--转载

    原文地址:https://www.centos.bz/2011/04/linux-centos-phpmyadmin-install/ 安装好PHP,Apache和MySQL程序后,为了管理MySQL ...

  7. &lt;九度 OJ&gt;题目1012:畅通project

    题目描写叙述: 某省调查城镇交通状况,得到现有城镇道路统计表.表中列出了每条道路直接连通的城镇.省政府"畅通project"的目标是使全省不论什么两个城镇间都能够实现交通(但不一定 ...

  8. BigQuery分析GitHub上的C#

    BigQuery分析GitHub上的C# 一年多以前,Google 在GitHub中提供了BigQuery用于查询的GitHub上的开源代码(open source code on GitHub av ...

  9. Android5.0(Lollipop) BLE蓝牙4.0+浅析code(二)

    作者:Bgwan链接:https://zhuanlan.zhihu.com/p/23347612来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. Android5.0(L ...

  10. 搭建MHA问题汇总

    1,Can't exec "mysqlbinlog": No such file or directory at /usr/share/perl5/vendor_perl/MHA/ ...