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+..+ ...
随机推荐
- PHP之会话控制小结
会话控制是一种跟踪用户的通信方式,使用会话控制主要基于以下几点:由于http协议的无状态性,使得不能通过协议来建立两次请求之间的关联:对于通常的页面之间的数据传递方式get和post而言,主要处理参数 ...
- asp.net服务器页面处理过程
一.静态页面.动态页面区别 静态页面是服务端直接从硬盘里面读取然后发回去,动态页面就要创建这个页面类的对象,调用对象的方法,方法里面什么就发回什么.浏览器请求asp.net页面实际是请求asp.net ...
- Java——String.split()函数
在java doc里有 String[] java.lang.String.split(String regex) Splits this string around matches of the g ...
- 总结&记录
一.Git(linux命令) 1.tar 压缩/解压 -c 建立一个压缩文件(create) -x 解压一个压缩文件 -t 查看tarfile中文件 -z 是否具有gzip的属性?是否需要用gzip ...
- ora 32021 设置参数时参数值长度超过255处理办法
alter system set db_file_name_convert='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA-.' scope=spfi ...
- 关于四字节字符入库时错误的解决方案(Incorrect string value: '\xF0\x9F\x99\x8F' for column 'Reply_Content' at row 1)
1. 将表字段字符集设置成utf8mb4 2. 执行插入前执行:SET NAMES utf8mb4; 如: SET NAMES utf8mb4; INSERT test(Content) VALUES ...
- leetcode之Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from W ...
- [java学习笔记]JDK的安装和环境变量的配置
1.JDK的下载和安装 jdk(java development kit)是java提供给我们的一套java开发工具,它必运行在JVM(java虚拟机)上,java语言的跨平台性就是利用java运行在 ...
- 通过 ANE(Adobe Native Extension) 启动Andriod服务 推送消息(五)
这一节,用个简单的例子来调用下之前生成的service.ane 首先建一个flex手机项目 然后在构建路径中把ane引进来 可以看到此ane支持Android平台. serviceMobile.mxm ...
- 《APUE》第四章笔记(1)
1.引言 本章介绍文件系统的特征和文件的性质.从stat函数开始,逐个说明stat结构的每一个成员以了解文件的所有属性.在此过程中,还将会说明修改这些属性的各个函数,并更详细地查看UNIX文件系统的结 ...