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

简单题. 删去结尾的不是$0$的数字,保证结尾连续的$k$个都是$0$,如果不能做到,就保留一个$0$. #include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include<vector> #include<cstdio> #include<cstring> #in…
B. Weird Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the given number of n Polycarp…
[题目链接]:http://codeforces.com/contest/779/problem/B [题意] 问你要删掉几个数字才能让原来的数字能够被10^k整除; [题解] /* 数字的长度不大; 让你删掉最小的数字个数 使得这个数字能被10^k整除; 搜索; 枚举哪些数字被删掉了; bool记录; 最后再全部乘起来; 枚举删掉1个,删掉两个即可.3.4...; 注意前导0只能有一个的情况就好 */ [完整代码] #include <bits/stdc++.h> using namespa…
暴搜 #include<cstdio> #include<algorithm> using namespace std; int n,K,Div=1,a[21],m,ans=100; bool vis[21]; void calc(int now) { int t=0; bool flag=0; for(int i=m;i>=1;--i) if(!vis[i]) { if((!flag) && a[i]==0) return; t=t*10+a[i]; fla…
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia. It is widely known that Uzhlyandia has n cities connected with m bidirectional roads. Also, there are no two roads in the countr…
  A. Rounding   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with …
D. Weird journey time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia. I…
题意:给定n个点,m条边,问能否找到多少条符合条件的路径.需要满足的条件:1.经过m-2条边两次,剩下两条边1次  2.任何两条路的终点和起点不能相同. 欧拉路的条件:存在两个或者0个奇度顶点. 思路:首先把给每条边都再增加一条边,所有点的度数都是偶数.每条边分为普通边和自环边. 1.删去两条没有公共顶点的普通边,会有四个点的度数变成奇数,不符合欧拉路. 2.删去两条有公共顶点的普通边,会有两个点的度数成为奇数,符合 2.删去一个自环边和一个普通边,会有两个点的度数成为奇数,符合 4.删去两条自…
题意: Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10k. For example, if k = 3, in the number 3…
题意: 给出无向图. good way : 仅有两条边只经过一次,余下边全经过两次的路 问你共有多少条不同的good way. 两条good way不同仅当它们所经过的边的集合中至少有一条不同 (很关键) 存在多个边连通分量的情况肯定是0. 当确定某两条边只经过一次的时候: 由于经过边的顺序不重要,余下边全经过两次,至多只有一条good way 那么把剩下经过两次的边拆分成两条经过一次的边,记现在的图是新图 原图中是否存在good way 就等价于新图中是否存在欧拉路 暴力枚举两条边判断肯定是要…