CodeForces 248B Chilly Willy

来源:互联网 发布:4g网络优化初级工程师 编辑:程序博客网 时间:2024/06/07 05:57

Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 235 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 (235 and7). 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 test(s)
input
1
output
-1
input
5
output
10080
题意很简单就不提了 要找到210的倍数 很明显只用考虑后三位  最后一位一定为0,因此找规律可以得到6个数一个循环
"05", "08", "17", "02", "20", "11"
代码如下:
#include <stdio.h>    void solve(int n){      char a[7][3]={"05", "08", "17", "02", "20", "11"};      if (n <= 3) {          printf("%d\n", n == 3 ? 210 : -1);          return ;      }      int tmp = (n - 4) % 6;      printf("1");      for (int i = 0; i < n - 4; ++ i)          printf("0");      printf("%s0\n", a[tmp]);  }    int main(){      int n;      while (~scanf("%d", &n)){          solve(n);      }      return 0;  }  


0 0