您的位置:首页 > 其它

B. Chilly Willy

2016-06-02 13:59 176 查看
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 ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: