Title address: http://acm.nyist.net/JudgeOnline/problem.php?pid=34?? Describe

Legend has it that Han Xin intelligence, never directly counted the number of their troops, as long as the soldiers have a row of three people, five people a row, seven people a row to change formation, and he only one eye at a time the team's exploited know the total number. Enter 3 non-negative integer a,b,c, indicating the number of exploited per formation (a<3,b<5,c<7), the minimum value of the total number of outputs (or no solution is reported). The total number of known people is not less than 10, not more than 100.

Input

Enter 3 non-negative integer a,b,c, indicating the number of exploited per formation (a<3,b<5,c<7). For example, Input: 2 4 5

Output

The minimum value of the total number of outputs (or no solution is reported, i.e. output no answer). Example, output: 89

Sample input

2 1 6

Sample output

41?? Code:? #include <stdio.h>

int main ()

{

???? int a = 0;

???? int b = 0;

???? int c = 0;

????

???? int result = 10;

????

???? scanf ("%d%d%d", &a,&b,&c);

????

???? for (; result<=100;++result)

???? {

????????? If (result% 3 = = a &&

?????????????? Result% 5 = = B &&

?????????????? Result% 7 = = c)

????????? {

?????????????? Break

????????? }???????????????????

???? }

????

???? If (Result >= && result <= 100)

???? {

????????? printf ("%d\n", result);

???? }

???? Else

???? {

????????? printf ("No answer\n");

???? }

????

???? return 0;

}?? Additional knowledge: =============== Han soldiers of is an interesting guessing game. If you take a broad bean (the number about 100 or so), first 3 grains of 3 grains, until 3 grains, the remainder is recorded, the second 5 grains of 5 grains, and then the remainder is recorded; the third time is 7 grains a number, the remainder is recorded. Then according to the remainder of each time, you can know how many beans you have taken. If you don't believe it, you can test it. For example, if 3 tablets a few 1 tablets, 5 tablets a few 2 tablets, 7 tablets a few 2 grains, then, the original broad bean has how many grains?

This kind of topic seems to be difficult to calculate, but in ancient times in our country there is an algorithm, the name is also many, the song called it "Ghost Valley", also known as "Partition calculation"; Yang Hui called it "tube cutting"; and the more popular name is "Han Xin soldiers of". Originally described this kind of algorithm is a book called "grandson of the Sutra", later in the Song Dynasty after the promotion of Mathematicians Qin Jiushao, and found an algorithm, called "Big Yan seeking a technique." This is a very famous problem in the history of mathematics, which is commonly referred to by foreigners as the "Chinese remainder theorem". As for its algorithm, in the "grandson of the book" already has the explanation, and later also circulated such a mnemonics:

Three people with 70 thin,

Five trees Plum blossom 21 sticks,

Seven son Reunion is half a month,

Except Bai to know.

This is the calculation method of Han Xin soldiers of, it means: usually with 3 of the remainder of a number, it is used 70 to multiply (because 70 is a multiple of 5 and 7, but also 3 to remove the number of the remaining 1); 5 is the remainder of a number, which is multiplied by 21 (because 21 is a multiple of 3 and 7, and the number of the remainder 5 is removed by 1) , 7 a number of remainder, will it use 15 to multiply (because 15 is a multiple of 3 and 5, and 7 to remove the number of remaining 1), add these numbers, if more than 105, minus 105, if the remaining number is greater than 105, then minus 105, until the count is smaller than 105. In this way, the number obtained is the original number. According to this principle, you can easily put the previous five topics into a formula:

1x70+2x21+2x15-105

=142-105

=37

So, as you can see, this pile of beans has 37 capsules. ============? So you can simplify the solution based on this calculation, without the need for all data traversal to calculate it?

#include <iostream>

using namespace Std;

int main ()

{

???? int a,b,c;

???? cin>>a>>b>>c;

???? int n= (a*70+b*21+c*15)%105;

???? if (n>100| | N<10) cout<< "No Answer" <<endl;

???? else cout<<n<<endl;

} ? ? ? ???

10-Language Introduction-10-Han soldiers of