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 }
  • 相关阅读:
    链表问题----反转部分单向链表
    HTTP请求详解
    链表问题----删除链表的中间节点和a/b处的节点
    链表问题----删除倒数第K个节点
    栈和队列----最大值减去最小值小于等于num的子数组的数量
    栈和队列----求最大子矩阵的大小
    TCP/IP、Http、Socket的区别
    栈和队列----生成窗口的最大值数组
    linux根文件系统制作,busybox启动流程分析
    linux 内核启动流程分析,移植
  • 原文地址:https://www.cnblogs.com/hyq123456/p/5427731.html
Copyright © 2011-2022 走看看