CodeForces 248B Chilly Willy

B. Chilly Willy
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (2,35 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.

Examples
input
1
output
-1
input
5
output
10080

规律题
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 100000 + 10;

int main()
{
    int n;
    int ans;
    while (scanf("%d", &n) != EOF){
        if (n < 3)
            printf("-1\n");
        else if (n == 3)
            printf("210\n");
        else{
            printf("1");
            for (int i = 0; i < n - 4; i++){
                printf("0");
            }
            int ans = (n - 4) % 6;
            if (ans == 0)
                printf("05");
            if (ans == 1)
                printf("08");
            if (ans == 2)
                printf("17");
            if (ans == 3)
                printf("02");
            if (ans == 4)
                printf("20");
            if (ans == 5)
                printf("11");
            printf("0\n");
        }
    }
    return 0;
}

#include<cstdio>
int i,p,n;
int main(){
	scanf("%d",&n);
	if(n<=3)printf("%d\n",n<=2?-1:210);
	else{
		printf("1");
		for(p=50,i=1;i<=n-4;++i)
			printf("0"),p=p*10%210;
		printf("%03d\n",p);
	}
}


你可能感兴趣的:(CodeForces 248B Chilly Willy)