博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
阅读量:7199 次
发布时间:2019-06-29

本文共 1167 字,大约阅读时间需要 3 分钟。

 

1 /* 2     构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 3 */ 4 #include 
5 #include
6 #include
7 #include
8 using namespace std; 9 10 const int MAXN = 1e3 + 10;11 const int INF = 0x3f3f3f3f;12 int a[MAXN];13 14 int main(void) //Codeforces Round #206 (Div. 2) A. Vasya and Digital Root15 {16 //freopen ("A.in", "r", stdin);17 int k, d;18 while (scanf ("%d%d", &k, &d) == 2)19 {20 if (d == 0 && k > 1) {puts ("No solution"); continue;}21 if (k >= d)22 {23 for (int i=1; i<=d; ++i) putchar ('1');24 for (int i=1; i<=k-d; ++i) putchar ('0');25 puts ("");26 }27 else28 {29 if (9 * k < d) {puts ("No solution"); continue;}30 for (int i=1; i<=k; ++i) a[i] = d / k;31 int res = d % k;32 for (int i=1; i<=res; ++i) a[i]++;33 for (int i=1; i<=k; ++i) printf ("%d", a[i]);34 puts ("");35 }36 37 }38 39 return 0;40 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4555632.html

你可能感兴趣的文章
C# OpenFileDialog And SaveFileDialog
查看>>
windows cmd color颜色设置
查看>>
22:按照字典输出字符串
查看>>
HDU 1108
查看>>
【Linux】理解setuid()、setgid()和sticky位
查看>>
下拉菜单 - - css
查看>>
LUA 环境
查看>>
昨日我是谁,今日谁是我
查看>>
hadoop实例
查看>>
JAVA之Exchanger
查看>>
菜鸟--shell脚本编写之解决问题篇
查看>>
java 多线程学习
查看>>
LeetCode 404: Sum of Left Leaves
查看>>
Alpha冲刺Day9
查看>>
ARC085F(动态规划,线段树)
查看>>
HDU3127:WHUgirls(二维完全背包)
查看>>
npm常用命令
查看>>
HTML 表格
查看>>
Kotlin入门(22)适配器的简单优化
查看>>
代码外的任务很精彩 ---Software project survival guide 读书报告
查看>>