Algorithm
You are given three positive integers a, b, c (a<b<c). You have to find three positive integers x, y, z such that:
Here pmodq denotes the remainder from dividing p by q. It is possible to show that for such constraints the answer always exists.
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤10000) — the number of test cases. Description of the test cases follows.
Each test case contains a single line with three integers a, b, c (1≤a<b<c≤108).
For each test case output three positive integers x, y, z (1≤x,y,z≤1018) such that xmody=a, ymodz=b, zmodx=c.
You can output any correct answer.
4 1 3 4 127 234 421 2 7 8 59 94 388
12 11 4 1063 234 1484 25 23 8 2221 94 2609
In the first test case:
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int a, b, c;
cin>>a>>b>>c;
cout<<(a+b+c)<<" "<<(b+c)<<" "<<(c)<<endl;
}
}
Copy The Code &
Try With Live Editor
Input
1 3 4
127 234 421
2 7 8
59 94 388
Output
1063 234 1484
25 23 8
2221 94 2609
Demonstration
Codeforcess Solutin 1684-B B. Z mod X = C ,C++, Java, Js and Python ,1684-B,Codeforcess Solutin