B. Chilly Willy

http://codeforces.com/problemset/problem/248/B

e , 看错题。。 找能被2,3,5,7整除的最小的数,要求长度为n  不会推,找的规律

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
const int maxx = 100000+10 ;
//string s[maxn] ;
int leng(long long x){
    int len = 0 ;
    while(x){
        x/=10 ;
        len++;
    }
    return len ;
}
long long tp ;
long long Find(long long x,int l){
    if(leng(x)>=l) {
            return tp = min(x,tp) ;

    }
    if(leng(x)<l) {
        tp = Find(x*3,l) ;
        tp = Find(x*5,l) ;
        tp = Find(x*2,l) ;
        tp = Find(x*7,l) ;
    }
}
void print(long long x){
    long long t = x ;
    int num = 1 ;
    while(t>1){
        if(t%2==0){
                t/=2;
                num*=2;
            cout << (num) << endl;
        }
        if(t%3==0){
                t/=3;
                num*=3;
            cout << num << endl;
        }
        if(t%5==0){
                t/=5;
                num*= 5;
            cout << num << endl;
        }
        if(t%7==0){
                t/=7;
                num*=7;
            cout << num << endl;
        }
    }
}
long long pow(long long &a,int x) {
    while(x--){
        a*=10 ;
    }
    return a ;
}
/*
210

4 1050
5 10080
6 100170
7 1000020
8 10000200
9 100000110
*/
int main(){
    long long tmp ;
//    int i = 2 ;
//    for(long long j = 3 ; j < 18 ; ++j )
//    for(long long i = pow(10,j) ; ; ++i){
//        if(i%2==0&&i%3==0&&i%5==0&&i%7==0) {
//            cout << i <<endl;
//            break;
//        }
//    }
    int n ;
    string a[6] = {"110","050","080","170","020","200"} ;
    while(cin >> n){
          if(n<3) cout << -1<<endl;
        else if(n==3) cout << 210 << endl;
        else {
            n-=3 ;
            cout << 1 ;
            for(int i = 1 ; i <= n-1 ; ++i){cout <<0;}
            cout << a[n%6] << endl;
        }
    }
    return 0 ;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值