Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- long long UCLN(long long a, long long b){
- if(b==0){
- return a;
- } else {
- return UCLN(b,a%b);
- }
- }
- long long BCNN(long long a, long long b){
- return (a*b/UCLN(a,b) );
- }
- int main(){
- long long x,y,z,m,ti,n;
- cin>>m;
- while (m--){
- cin>>x>>y>>z>>n;
- ti=BCNN(x,y);
- ti=BCNN(ti,z);
- n=pow(10,n-1);
- if ((ti/n)>9){
- cout<<"-1"<<endl;
- } else {
- if (ti>=n){
- cout<<ti<<endl;
- }else{
- if ((n%ti)==0){
- cout<<ti*((n/ti))<<endl;
- }else{
- cout<<ti*((n/ti)+1)<<endl;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement