zoukankan      html  css  js  c++  java
  • 2019牛客暑期多校训练营(第五场) digits 2

    时间限制:C/C++ 1秒,其他语言2秒

    空间限制:C/C++ 262144K,其他语言524288K
    Special Judge, 64bit IO Format: %lld

    题目描述

    You are given a positive integer n which is at most 100.

    Please find a positive integer satisfying the following conditions:

    1. The sum of all digits of this number is dividable by n.

    2. This number is also dividable by n.

    3. This number contains no more than 10^4 digits.

    If such an integer doesn't exist, output "Impossible" (without quotation marks).
    If there are multiple such integers, please output any one.

    输入描述:

    The first line contains one integer T indicating that there are T tests.

    Each test consists an integer n in a single line.

    * 1≤T≤1001 le T le 1001T100

    * 1≤n≤1001 le n le 1001n100

    输出描述:

    For each query, output one line containing the answer. The number you print cannot have leading zeros. If there are multiple answers, you can print any. If such an integer doesn't exist, output "Impossible" (without quotation marks) in a single line.
    示例1

    输入

    3
    1
    9
    12

    输出

    1
    666666
    888

    题意:已知数字N(<=100),寻找一个数字,使这个数字和这个数字各位上的数字之和都能被N整除。如果存在,则任意输出一个答案,反之,输出"Impossible"。

    题解:
    简单数学若N=12,则12,1212,121212,12121212,……都能被12整除,与此同时还要满足各位数字之和也要被N整除,令N的各位数字之和为m,则(x*m)÷N为整数,得x=N即可。即输出N个数字N。

    代码:
    #include<iostream>
    using namespace std;
    int main()
    {
      int n,i,T;
      scanf("%d",&T);
      while(T--)
      {
        scanf("%d",&n);
        for(i=1;i<=n;i++) printf("%d",n);
        printf("
    ");
      }
      system("pause");
      return 0;
    }
    本博客仅为本人学习,总结,归纳,交流所用,若文章中存在错误或有不当之处,十分抱歉,劳烦指出,不胜感激!!!
  • 相关阅读:
    20161101学习笔记
    20161031学习笔记
    20161028学习笔记
    20161027学习笔记
    ReentrantLock Condition
    ReentrantLock 重入锁
    CountDownLatch用法与原理
    场景化解释 AQS原理
    Atomic
    多线程工具类
  • 原文地址:https://www.cnblogs.com/VividBinGo/p/11291550.html
Copyright © 2011-2022 走看看