zoukankan      html  css  js  c++  java
  • 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门

     1 /*
     2     构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则
     3 */
     4 #include <cstdio>
     5 #include <algorithm>
     6 #include <cstring>
     7 #include <cmath>
     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 Root
    15 {
    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         else
    28         {
    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 }
    编译人生,运行世界!
  • 相关阅读:
    HyperLeger Fabric开发(三)——HyperLeger Fabric架构
    WPF设计の画刷(Brush)
    WPF设计の画刷(Brush)
    WPF设计の画刷(Brush)
    Mina Basics 02-基础
    内置方法
    py-opp 类(class)
    Python 学习目录
    py-函数进阶
    py-函数基础
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4555632.html
Copyright © 2011-2022 走看看