e

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);  
        }  
    }  
  
}  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值