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 首页定时生成静态页面
往往首页的js,商务通代码加的太多,导致页面访问速度变慢,可以把首页有动态变为静态进行访问,访问速度会有所提升,不过如果更新首页数据,并不能及时更新,而是你规定的时间内固定更新一次 代码如下: < ...
- SpringMVC注册拦截器
方法1: 拦截所有URL <mvc:interceptors> <bean class="cn.ciss.interceptor.LoginInterceptor" ...
- ASP中双引号单引号和&连接符使用技巧
ASP中双引号单引号和&连接符使用技巧 一.ASP中处在双引号中的可以是任意的字符.字符串,HTML代码 1.<%response.write ("I am here" ...
- ServerRelativeUrl与Url
文件的file.ServerRelativeUrl,是文件相对于网站集的地址,file.Url是文件相对于本网站的地址.
- php的标记形式
共三种: 推荐第一种,第三种需要在php.ini中配置 效果: 第三种配置 将short_open_tag=Off改为On重启Apache就可以了
- Windows Server 2008 R2安装IIS
在"服务器管理器"中选择"添加角色". 在"服务器角色"步骤选择"Web 服务器(IIS)". "角色 ...
- ###《Effective STL》--Chapter7
点击查看Evernote原文. #@author: gr #@date: 2014-08-31 #@email: forgerui@gmail.com Chapter7 在程序中使用STL Topic ...
- IOS- 最简单的反向传值- block
block 常用于反向传值 声明 返回值类型 (^block)(参数列表) 调用 闭包的名字=^(参数列表){}: 闭包的名字(): 如: void(^aaaaa)(int num,NSString ...
- 【制作镜像Win*】特殊配置
下载disk.config: wget http://10.254.3.75/images/configdrive/disk.config 修改libvirt.xml,更换cdrom为disk.con ...
- 用VIM写作
Write in VIm 1.Writing in Vim by Dr. Bunsen