codeforces A. Vasya and Digital Root 解题报告
题目链接:http://codeforces.com/problemset/problem/355/A
题目意思:找出某个经过最多四次dr(n)操作等于d的k位数。
千万不要想得太复杂,想得越简单越好。由于它允许dr(n)的操作最多只能是四次,那么操作一次肯定是符合条件的。也就是经过一次dr(n)操作就能得出直接结果d的数(有k位)。
由于这个数不能有前导0,非常简便的一个方法是,这个k位数是这样的:d000...00(0的个数等于k-1)。要特别注意,什么时候应该输出“No solution”。答案是 k >= 2 并且 d = 0。000这样的数,你不会认为是符合合法数字的标准吧?
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std; int main()
{
int k, d, i;
while (scanf("%d%d", &k, &d) != EOF)
{
if (d == && k == )
printf("0\n");
else if (d == && k > )
printf("No solution\n");
else
{
printf("%d", d);
for (i = ; i < k-; i++)
{
printf("");
}
printf("\n");
}
}
return ;
}
codeforces A. Vasya and Digital Root 解题报告的更多相关文章
- codeforces B. Vasya and Public Transport 解题报告
题目链接:http://codeforces.com/problemset/problem/355/B 题目意思:给出四种票种,c1: 某一部bus或者trolley的单程票(暗含只可以乘坐一次):c ...
- codeforces 355A Vasya and Digital Root
题意就是找出一个长度为k的整数,使得它的root为d,k的可能取值为1-1000. 第一眼看到这个题,无从下手,想到那么长的数,暴力肯定超时.其实不然,题目要求只要输出任何一个满足条件的即可,因为任何 ...
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- 【九度OJ】题目1124:Digital Roots 解题报告
[九度OJ]题目1124:Digital Roots 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1124 题目描述: T ...
- codeforces 495A. Digital Counter 解题报告
题目链接:http://codeforces.com/problemset/problem/495/A 这个题目意思好绕好绕~~好绕~~~~~,昨天早上做得 virtual 看不懂,晚上继续看还是,差 ...
- Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
#include <iostream> using namespace std; int main(){ int k,d; cin >> k >>d; ) { k ...
- codeforces Vasya and Digital Root
/* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ /** * 当时比赛时,想得复杂了,也想偏了, * 1).写出来之后,结果达到了预期 ...
- codeforces C1. The Great Julya Calendar 解题报告
题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...
- codeforces B. Eugeny and Play List 解题报告
题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...
随机推荐
- 【BZOJ-3545&3551】Peaks&加强版 Kruskal重构树 + 主席树 + DFS序 + 倍增
3545: [ONTAK2010]Peaks Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1202 Solved: 321[Submit][Sta ...
- 【poj1009】 Edge Detection
http://poj.org/problem?id=1009 (题目链接) 不得不说,poj上的水题还是质量非常高的= =,竟然让本大爷写了一下午. 转自:http://blog.sina.com.c ...
- 更改动软代码生成器模板 验证Model数据合法性
1.第一个模板 判断字段是否为空 类 IsNullableType.cmt static public partial class CommonType { public static bool Is ...
- FCK编辑器漏洞总结
1.查看编辑器版本FCKeditor/_whatsnew.html————————————————————————————————————————————————————————————— 2. Ve ...
- css 伪类::after ::beftor 的使用方式
注释:对于 IE8 及更早版本中的 :before,必须声明 . ::before和::after这两个主要用来给元素的前面或后面插入内容,这两个常用"content"配合使用,见 ...
- 分享一个导航条哈(⊙o⊙)…
原文:http://www.sharejs.com/js/menu/1601 CSS样式表: <!--[if lt IE 9]> <script src="http://h ...
- xpath基础知识
相关链接: http://www.ruanyifeng.com/blog/2009/07/xpath_path_expressions.html 自动生成xpath的工具: http://blog.s ...
- PHP引用(&)初探:函数的引用返回
函数的引用返回 先看代码: <?php function &test() { static $b=0;//申明一个静态变量 $b=$b+1; echo $b; return $b; } ...
- Windbg对过滤驱动DriverEntry函数下断点技巧
方法1: 1> 先用DeviceTree.exe查看指定的过滤驱动的Load Address(加载地址) 2> 再用LordPE.EXE查看指定过滤驱动文件的入口点地址 3> 计算过 ...
- Java笔记--泛型总结与详解
泛型简介: 在泛型没有出来之前,编写存储对象的数据结构是很不方便的.如果要针对每类型的对象写一个数据结构, 则当需要将其应用到其他对象上时,还需要重写这个数据结构.如果使用了Object类型, ...