zoukankan      html  css  js  c++  java
  • Codeforces Round #324 (Div. 2) A

    A. Olesya and Rodion
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them.

    Your task is: given the n and t print an integer strictly larger than zero consisting of n digits that is divisible by t. If such number doesn't exist, print  - 1.

    Input

    The single line contains two numbers, n and t (1 ≤ n ≤ 100, 2 ≤ t ≤ 10) — the length of the number and the number it should be divisible by.

    Output

    Print one such positive number without leading zeroes, — the answer to the problem, or  - 1, if such number doesn't exist. If there are multiple possible answers, you are allowed to print any of them.

    Examples
    Input
    3 2
    Output
    712

    题意; 输出一个数 长度为n并且为t的倍数 不存在 则输出-1

    题解: n个t 组成的数一定是t的倍数
    考虑特殊 t=10的情况 (水)

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<queue>
     5 #include<stack>
     6 #include<cmath>
     7 #define ll __int64 
     8 #define pi acos(-1.0)
     9 #define mod 1000000007
    10 using namespace std;
    11 int n,t;
    12 int main()
    13 {
    14     scanf("%d %d",&n,&t);
    15     if(t<10)
    16     {
    17         for(int i=1;i<=n;i++)
    18             printf("%d",t);
    19             cout<<endl;
    20     }
    21     if(t==10)
    22     {
    23         if(n==1)
    24         cout<<"-1"<<endl;
    25         else
    26         {
    27             for(int i=1;i<n;i++)
    28             printf("1",t);    
    29              cout<<"0"<<endl;
    30         }
    31     }
    32     return 0;
    33  } 
  • 相关阅读:
    linux笔记
    restful课程凌杂知识点
    Django中间件执行流程
    restful知识点之二restframework视图
    restful知识点之一CBV
    可变长参数
    函数的重点内容
    文件的高级应用及修改的两种方式
    文件的三种打开方式及with管理文件上下文
    字符编码
  • 原文地址:https://www.cnblogs.com/hsd-/p/5550821.html
Copyright © 2011-2022 走看看