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  } 
  • 相关阅读:
    oauth2-server-php for windows 的那些坑 (研究中...)
    你使用 Web 平台安装程序命令行工具
    Window 下安装 Redis
    windows下安装redis 以及phpredis的扩展 (windows redis php&php7)
    windows下redis的安装配置和php扩展使用phpredis
    常用网络端口
    PHP OAuth 2.0 Server
    Database Setup
    php各版本下载
    纯 html 以及 js 多域名跳转
  • 原文地址:https://www.cnblogs.com/hsd-/p/5550821.html
Copyright © 2011-2022 走看看