e
Time Limit: 2000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Dreamtale loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7, he came up a game that were connected with them.
Deamtale wants to find the minimum number of length n, such that it is simultaneously divisible by all numbers Dreamtale 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.
输入
A single input line contains a single integer n (1≤n≤10^5).
输出
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.
示例输入
1 5
示例输出
-1 10080
提示
来源
Rocky
示例程序
#include<stdio.h>
int a[1000000];
int main()
{
int i,j,n,m,k,t;
while(scanf("%d",&n)!=EOF)
{
if(n==1||n==2)
printf("-1\n");
if(n==3)
printf("%d\n",210);
if(n>=4)
{
a[0]=1;
a[1]=0;
k=2;
m=50;
for(i=4;i<n;i++)
{
m=m*10;
t=m;
while(m>=210)
m-=210;
if(m<100&&t>=1000)
{
a[k++]=0;
a[k++]=0;
}
else if(t>=100&&m<100)
a[k++]=0;
else if(t>=1000&&m>=100)
a[k++]=0;
}
for(i=0;i<k;i++)
printf("%d",a[i]);
printf("%d\n",m);
}
}
}