codeforces Vasya and Digital Root
/*
* c.cpp
*
* Created on: 2013-10-7
* Author: wangzhu
*/ /**
* 当时比赛时,想得复杂了,也想偏了,
* 1)、写出来之后,结果达到了预期的结果,不过和给出的输出不一样,糊涂了
* 2)、想法太复杂了
*
* 比赛之后,看了别人的,原来如此:
*结果不唯一,
*当根为0,但位数大于1,则没有结果,因为位数大于1,最后的根必然大于0,故没有结果;
*当不为0,则应是根后面跟位数减去一个零,即是结果。
*/
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
int k,d;
while(~scanf("%d%d",&k,&d)) {
if(d == && ( k > )) {
printf("No solution\n");
} else {
printf("%d",d);
for(int i = ;i < k;i++) {
printf("");
}
printf("\n");
}
}
return ;
}
codeforces Vasya and Digital Root的更多相关文章
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- codeforces A. Vasya and Digital Root 解题报告
题目链接:http://codeforces.com/problemset/problem/355/A 题目意思:找出某个经过最多四次dr(n)操作等于d的k位数. 千万不要想得太复杂,想得越简单 ...
- codeforces 355A Vasya and Digital Root
题意就是找出一个长度为k的整数,使得它的root为d,k的可能取值为1-1000. 第一眼看到这个题,无从下手,想到那么长的数,暴力肯定超时.其实不然,题目要求只要输出任何一个满足条件的即可,因为任何 ...
- 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 Beta Round #10 C. Digital Root 数学
C. Digital Root 题目连接: http://www.codeforces.com/contest/10/problem/C Description Not long ago Billy ...
- codeforces 10C Digital Root(非原创)
Not long ago Billy came across such a problem, where there were given three natural numbers A, B and ...
- Digital root(数根)
关于digital root可以参考维基百科,这里给出基本定义和性质. 一.定义 数字根(Digital Root)就是把一个数的各位数字相加,再将所得数的各位数字相加,直到所得数为一位数字为止.而这 ...
- 数字根(digital root)
来源:LeetCode 258 Add Dights Question:Given a non-negative integer num , repeatedly add all its digi ...
- 【HDOJ】4351 Digital root
digital root = n==0 ? 0 : n%9==0 ? 9:n%9;可以简单证明一下n = a0*n^0 + a1*n^1 + ... + ak * n^kn%9 = a0+a1+..+ ...
随机推荐
- Exchanger, Changing data between concurrent tasks
The Java concurrency API provides a synchronization utility that allows the interchange of data betw ...
- Android线控的使用
实现方式一:只能在程序为前台时监控 在Activity中即可监听 @Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log ...
- StrHelper
public class StrHelper { private static string passWord; //加密字符串 /// <summary> /// 判断输入是否数字 // ...
- tomcat根据繁忙线程数对keepalive进行动态调整
众所周知,Keep-Alive功能使客户端到服务器端的连接持续有效,当出现对服务器的后继请求时,Keep-Alive功能避免了建立或者重新建立连接.我们经常所用的tomcat服务器就支持HTTP Ke ...
- Unity中使物体自动寻路的方法
在做一个FPS游戏时,需要敌方自动找到玩家方位并向玩家移动,在查找资料(并走了不少坑)后,我试了三个方法,经测试,这三个方法都能实现自动寻路功能. 方法一:使用Mathf.Lerp()方法 代码很简单 ...
- 菜鸟的MySQL学习笔记(一)
本学习笔记是照搬慕课网<与MySQL的零距离接触>内容,特此感谢! 1-1 mysql的安装与配置 Windows环境下的MSI安装: 1.安装: 双击MSI文件->用户协议-> ...
- mysql 数据库还原出错ERROR:Unknown command '\' mysql中断
其实造成这个问题的原因还是由于编码的问题,网站数据库设置的是gbk 的,mysql默认是gbk:但是在导出数据的时候导出了utf8的sql文件,不管我如何重新导入,在连接数据库后使用set names ...
- Java Web开发之详解JSP
JSP作为Java Web开发中比较重要的技术,一般当作视图(View)的技术所使用,即用来展现页面.Servlet由于其本身不适合作为表现层技术,所以一般被当作控制器(Controller)所使用, ...
- php 用户验证的简单示例
发布:thebaby 来源:net [大 中 小] 本文介绍下,在php中,进行用户登录验证的例子,这个是基于WWW-Authenticate登录验证的实例,有需要的朋友参考下吧. 大家是 ...
- poj 1113 Mall
Mall 水题:注意题目上面有一个至少离城堡的距离为L,其实思考一下就知道是指离凸包(凸多边形)的距离为L,这时很容易知道外围的圆的圆心角叠加之后就是一个整圆:和poj2187一样使用graham形成 ...