zoukankan      html  css  js  c++  java
  • codeforces #324 div 2 A. Olesya and Rodion

    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.

    Sample test(s)
    input
    3 2
    output
    712

    构造题.

    让构造任意一个n位数满足整除t

    由于t是个位数== 

    所以很水.

    -1的话只有n为1t为10的情况.

    具体见代码...写得有点丑QAQ

     1 /*************************************************************************
     2     > File Name: code/cf/#324/A.cpp
     3     > Author: 111qqz
     4     > Email: rkz2013@126.com 
     5     > Created Time: 2015年10月11日 星期日 23时32分46秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #include<cctype>
    21                  
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define ms(a,x) memset(a,x,sizeof(a))
    25 using namespace std;
    26 const int dx4[4]={1,0,0,-1};
    27 const int dy4[4]={0,-1,1,0};
    28 typedef long long LL;
    29 typedef double DB;
    30 const int inf = 0x3f3f3f3f;
    31 int n,t;
    32 int main()
    33 {
    34   #ifndef  ONLINE_JUDGE 
    35  //  freopen("in.txt","r",stdin);
    36   #endif
    37    cin>>n>>t;
    38    if (n==1&&t==10)
    39     {
    40     puts("-1");
    41     return 0;
    42     }
    43    if (n==1)
    44     {
    45     cout<<t<<endl;
    46     return 0;
    47     }
    48    if (t==10)
    49     {
    50     for ( int i = 1 ; i <=n-1 ; i++)
    51         cout<<1;
    52     cout<<0<<endl;
    53     return 0;
    54     }
    55    for ( int i = 1  ; i <= n ; i++)
    56        cout<<t;
    57    cout<<endl;
    58   
    59    
    60  #ifndef ONLINE_JUDGE  
    61   fclose(stdin);
    62   #endif
    63     return 0;
    64 }
    View Code
  • 相关阅读:
    工程结构
    生活决策
    工作原则概要与列表
    生活原则概要与列表
    在Windows2008下安装SQL Server 2005无法启动服务的解决办法
    MySQL启动提示High Severity Error解决方案
    知乎页面颜色个性化修改
    博客园 CodingLife 模板 翻页样式美化方法
    【翻译】GitHub Pages Basics 基本使用帮助【一】GitHub Pages 是什么?
    【翻译】GitHub Pages Basics 基本使用帮助【首页】
  • 原文地址:https://www.cnblogs.com/111qqz/p/4870477.html
Copyright © 2011-2022 走看看