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 == 0 && ( k > 1)) {
            printf("No solution\n");
        } else {
            printf("%d",d);
            for(int i = 1;i < k;i++) {
                printf("0");
            }
            printf("\n");
        }
    }
    return 0;
}

 

posted @ 2013-10-14 09:12  qingyezhu  阅读(222)  评论(0编辑  收藏  举报