Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- 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));
- }
- long long SCS(long long n){
- long long scs=0;
- while(n>0){
- n = n/10;
- scs++;
- }
- return scs;
- }
- int main() {
- int t;
- cin >> t;
- while(t--){
- long long x, y, z , n;
- cin >> x;
- cin >> y;
- cin >> z;
- cin >> n;
- long long boichung = BCNN(BCNN(x,y),z);
- if(SCS(boichung)>n){
- cout << -1 << endl;
- }else{
- if(SCS(boichung)==n){
- cout << boichung << endl;
- } else {
- long long sodautien=pow(10,n-1);
- long long sodu = sodautien % boichung;
- long long ketqua = sodautien + (boichung - sodu);
- cout << ketqua << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement