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 }
  • 相关阅读:
    HDU 5793 A Boring Question 2016多校第六场1001
    HDU 5803 Zhu’s Math Problem 2016多校第六场1011 数位dp
    HDU 5787 K-wolf Number 2016多校第五场1007 数位dp
    HDU 5791 Two 2016多校第五场1011 LCS
    HDU 5773 The All-purpose Zero 2016多校第四场1010 LIS
    HDU 5768 Lucky7 2016多校第四场1005
    hdu 5002 Tree(LCT裸题)
    Wannafly挑战赛1 C MMSet2
    hdu 5398 GCD Tree(LCT动态维护最大生成树)
    hdu 5967 小R与手机(LCT裸题)
  • 原文地址:https://www.cnblogs.com/hyq123456/p/5427731.html
Copyright © 2011-2022 走看看