原题链接:http://codeforces.com/problemset/problem/584/A
题意:给定两个数n和t,让你构造一个数满足n个位数和能整除t
解题思路:n个范围十分大,所以我们不可能是用平常的方法来找到我们想要的数的,而是直接猜想如果首位是t,其余的位上都补0,这个数是一定能整除t的,考虑特殊情况,则此题易解。
AC代码:
/*
*/
//低版本G++编译器不支持,若使用这种G++编译器此段应注释掉
//i为循环变量,a为初始值,n为界限值,递增
//i为循环变量, a为初始值,n为界限值,递减。
using namespace std;
const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为代码自定义代码模板***************************************//
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
ios::sync_with_stdio(false);//打消iostream中输入输出缓存,节省时间。
cin.tie(0); cout.tie(0);//可以通过tie(0)(0表示NULL)来解除cin与cout的绑定,进一步加快执行效率。
int n,t;
while(cin>>n>>t){
if(n==1&&t==10){
//这种情况无解。
cout<<"-1"<<endl;
}
else{
if(t==10){
//为了符合规律,补0之后肯定是10的倍数,所以让它变1.
t=1;
}
cout<<t;
rep(i,1,n-1){
cout<<"0";
}
cout<<endl;
}
}
return 0;
}