Educational Codeforces Round 107 (Rated for Div. 2)
B. GCD Length
题目大意:
给出a,b,gcd(a,b)的位数,输出符合条件的一组a,b。
思路:
一开始想复杂了,但是是很简单的构造题。
取a=a>b?a:b;
,保证a是最小的那个。
然后x=pow(10,a-1)+pow(10,c-1);
y=pow(10,b-1);
公倍数 pow(10,c-1);
正好是c位。
代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin>>t;
while(t--){
int x,y,z,a,b,c,n=0;
cin>>a>>b>>c;
x=pow(10,a-1)+pow(10,c-1);
y=pow(10,b-1);
cout<<x<<" "<<y<<"\n";
}
return 0;
}
结论:
就很巧妙,记住这类题型就好!