题目链接: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 解题报告的更多相关文章

  1. codeforces B. Vasya and Public Transport 解题报告

    题目链接:http://codeforces.com/problemset/problem/355/B 题目意思:给出四种票种,c1: 某一部bus或者trolley的单程票(暗含只可以乘坐一次):c ...

  2. codeforces 355A Vasya and Digital Root

    题意就是找出一个长度为k的整数,使得它的root为d,k的可能取值为1-1000. 第一眼看到这个题,无从下手,想到那么长的数,暴力肯定超时.其实不然,题目要求只要输出任何一个满足条件的即可,因为任何 ...

  3. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  4. 【九度OJ】题目1124:Digital Roots 解题报告

    [九度OJ]题目1124:Digital Roots 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1124 题目描述: T ...

  5. codeforces 495A. Digital Counter 解题报告

    题目链接:http://codeforces.com/problemset/problem/495/A 这个题目意思好绕好绕~~好绕~~~~~,昨天早上做得 virtual 看不懂,晚上继续看还是,差 ...

  6. Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    #include <iostream> using namespace std; int main(){ int k,d; cin >> k >>d; ) { k ...

  7. codeforces Vasya and Digital Root

    /* * c.cpp * * Created on: 2013-10-7 * Author: wangzhu */ /** * 当时比赛时,想得复杂了,也想偏了, * 1).写出来之后,结果达到了预期 ...

  8. codeforces C1. The Great Julya Calendar 解题报告

    题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...

  9. codeforces B. Eugeny and Play List 解题报告

    题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...

随机推荐

  1. BZOJ-1227 虔诚的墓主人 树状数组+离散化+组合数学

    1227: [SDOI2009]虔诚的墓主人 Time Limit: 5 Sec Memory Limit: 259 MB Submit: 914 Solved: 431 [Submit][Statu ...

  2. 异步http框架简介&实现原理

    1 )说明: Android开源代码:www.github.com 模拟一个异步http请求说明

  3. 多线程下载的原理&断点下载的原理

    1)多线程下载说明:

  4. javascript的字符串模板

    在其他语言存在字符串内插(string interpolation)或者叫变量内插(Variable interpolation).ES6中的称为template string. 模板字符串使用反引号 ...

  5. Python序列的切片操作与技巧

    切片操作 对于具有序列结构的数据来说,切片操作的方法是:consequence[start_index: end_index: step]. start_index: 表示是第一个元素对象,正索引位置 ...

  6. JS 动画基础

    获取元素的样式 getStyle函数 function getStyle(element, attr) { if(element.currentStyle) { //针对IE return eleme ...

  7. 单机安装TFS(转载)

    一.安装操作系统:windows server 2003 + Sp2具体步骤: 1.安装windows server 2003时选用工作组(默认为workgroup).由于在工作组环境中部署,因此使用 ...

  8. spingMVC<1>-xml文件配置

    ---恢复内容开始---

  9. jetty使用教程(嵌入eclipse开发)

    在eclipse下面建一个java project 建立目录结构如下: 二级目录: (备注jetty_test是工程的根目录,etc.lib.webRoot为其二级目录) 到jetty的官方网站(ht ...

  10. [Angularjs]ng-switch用法

    用法描述 ng-switch根据表达式的值显示或这隐藏对应部分.类似c#或者其他预览里面的switch用法.可以慢慢体会. 说道ng-switch就要说到子元素该怎么根据当前值进行变化.子元素可以通过 ...