Input:
The first line contains the number of test cases T. Each test case consists of a positive integer - M.
Output:
For each test case output two space-separated integers, the number of 1's and number of 0's in the magical string if Oz
touches the string M times.
Constraints:
1<= T <=20
1<= M <=90
Sample Input (Plaintext Link)
2
1
2
Sample Output (Plaintext Link)
0 1
1 1
Submit your solution here: Click here
It's All About Magic! HackerEarth Solution in C++
#include <iostream>
using namespace std;
int main()
{
int t = 0, m = 1, n, i, j, t1;
int a1 = 1, a2 = 1;
cout << "Enter the no of times Sample Input\n\n";
cin >> n;
cout << t << " " << m << endl;
for (i = 0; i < n; i++)
{
cout << a1 << " " << a2 << endl;
t1 = a1;
a1 = a2;
a2 = a2 + t1;
}
}
The Output of It's All About Magic! HackerEarth Solution
Similar to It's All About Magic!
- Exceptional Server Hackerrank Solution in C++
- Inherited Code Hackerrank Solution in C++
- Box It Hackerrank Solution in C++
- Classes and Objects Hackerrank Solution in C++
- Class Hackerrank Solution in C++
- Virtual Functions Hackerrank Solution in C++
- C++ Class Templates Hackerrank Solution in C++
- Operator Overloading Hackerrank Solution in C++
- Preprocessor Solution Hackerrank Solution in C++
- Multi-Level Inheritance Hackerrank Solution in C++
- Accessing Inherited Functions Hackerrank Solution in C++
- Print Pretty Hackerrank Solution in C++
- Maps STL Hackerrank Solution in C++
0 Comments: