zoukankan      html  css  js  c++  java
  • CQUOJ 9766 Chilly Willy

    Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.

    Chilly Willy wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Willy already knows (2, 3, 5 and 7). Help him with that.

    A number's length is the number of digits in its decimal representation without leading zeros.

     

    Input

    A single input line contains a single integer n (1 ≤ n ≤ 105).

     

    Output

    Print a single integer — the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist.

     

    Sample Input

    Input
    1
    Output
    -1
    Input
    5
    Output
    10080
     1 /*
     2 2016年4月24日16:55:26
     3 题意: 给定n  找到十进制数 长度为n的 能同时整除2 3 5 7的最小的数 
     4 
     5 要找到210的倍数 很明显只用考虑后三位  最后一位一定为0,
     6 因此找规律可以得到6个数一个循环
     7 "05", "08", "17", "02", "20", "11" 
     8 
     9 明显个鬼啊 
    10 */
    11 
    12 
    13 
    14 # include <iostream>
    15 # include <cstdio>
    16 # include <cstring>
    17 # include <algorithm>
    18 # include <queue>
    19 # include <vector>
    20 # include <cmath>
    21 # define LL long long 
    22 # define INF 0x3f3f3f3f
    23 using namespace std;
    24 const int N = 1e5 + 5;
    25 
    26 char s[6][3] = {"05", "08", "17", "02", "20", "11"};
    27 
    28 int main(void)
    29 {
    30     int n, tmp, i;
    31     while (~scanf("%d", &n)){
    32         if (n <= 2)
    33             printf("-1
    ");
    34         else if (n == 3)
    35             printf("210
    ");
    36         else {
    37             printf("1");
    38             for (i = 2; i <= n-3; i++)
    39                 printf("0");
    40             tmp = (n - 4) % 6;
    41             printf("%s0
    ", s[tmp]);
    42         }
    43     }
    44     
    45     return 0;    
    46 }
  • 相关阅读:
    使用docker部署微服务
    配置git仓库SSH秘钥,实现免密登录
    windows添加打印机失败
    流媒体之HLS与DASH
    docker安装mysql8.0
    去它的不要找客观原因
    idea提交代码到gitee报错:The requested URL returned error: 403
    使用docker compose微服务编排
    docker安装redis
    OpenGL环境安装
  • 原文地址:https://www.cnblogs.com/hyq123456/p/5427731.html
Copyright © 2011-2022 走看看