B. Chilly Willy

来源:互联网 发布:淘宝女内裤真人秀图片 编辑:程序博客网 时间:2024/06/16 19:42

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 ;}/*2104 10505 100806 1001707 10000208 100002009 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 ;}


0 0
原创粉丝点击