# Jessy's Friend - Acil Yardim

Problem 1 – Jessy’s Friend
Jessy is starting to study numbers, sequences of numbers and combinations of numbers in a more advanced level. She is trying to solve an exercise, which is rather easy for her to solve and to check with small numbers. However, it gets more complicated for her to figure it out with bigger numbers. She is very curious and she really wants to know what happens when bigger numbers are involved. Thus, as her friend, who studies programming, she has asked for your help.
Write a program that checks all possible combinations of pairs of numbers in a given interval and finds out for which pair the sum of its numbers is equal to a given ‘magic number’. If no such pair is found, let the user know that none of the pairs’ sum equals the ‘magic number’. (see examples)
Input
The input consists of 3 lines:
First line: You will receive the starting number for the given interval - startInterval
Second line: You will receive the last number for the interval - endInterval
Third line: You will get the so called ‘magic number’ - magicNumber
Output
The output consists of 1 line:
If you found a pair, which sum equals the ‘magic number’, print the following information:
"Combination N:{number of the combination} ({pair's first number} + {pair's second number} = {magic number})"
However, if you did not find any pair, which sum equals the ‘magic number’, print the following:
"{the total amount of combinations} combinations - neither equals {magic number}"
Constraints
startInterval - an integer within the range of [1…999]
endInterval – an integer within the range of [bigger than startInterval …1000]
magicNumber - an integer within the range of [1…10000]

Scroll down to see the examples.

Examples
Input    Output
1
10
5    Combination N:4 (1 + 4 = 5)
Explanation
All possible combinations of pairs with numbers from 1 to 10 are the following:
1 1, 1 2, 1 3, 1 4, 1 5, … 2 1, 2 2, …4 9, 4 10, 5 1 … 10 9, 10 10
The first pair, for which the sum of its numbers is equal to the magic number 5 is the 4th one (1 4).

Input    Output
23
24
20    4 combinations - neither equals 20
Explanation
All possible combinations of pairs with numbers from 23 to 24 are the following:
23 23, 23 24, 24 23, 24 24 (four in total)
There is no pair, which sum is equal to the magic number.

Input    Output
88
888
1000    Combination N:20025 (112 + 888 = 1000)

Input    Output
88
888
2000    641601 combinations - neither equals 2000

• Etiketler;
Cevap Yaz

Cevap yazabilmek için üye girişi yapmanız gerekiyor!

Yukarı Git