[PTA] 7-36 Han soldiers (10 minutes)

In the history of Chinese mathematics, a widely circulated "Han Xin Troops" story: Han Han emperor Liu Bang men generals, his heroic, resourcefulness superior, outstanding credit to the establishment of a Han Dynasty. It is said that the level of mathematics Han is also very superb, when he soldiers on, in order to know how many soldiers, while keep military secrets, let reported that the number of soldiers line up:

From 1 to 5 according to the number of packets, a note of the number of the last packet of a soldier;
then the number of packets from 1 to 6, the number of packets last note of a soldier is 5;
then the number of packets from 1-7, write down the number reported last a soldier is 4;
press the number reported from 1-11, a soldier reported the number of the last 10;
write a program to calculate the minimum number of Han soldiers.

Input Format:
This problem no input

Output formats:
the number of soldiers have at least the Han output.

#include <stdio.h>

int main()
{
    int i;
    for (i = 1;; i++) {
        if ((i % 5 == 1) && (i % 6 == 5) && (i % 7 == 4) && (i % 11 == 10)) {
            printf("%d\n", i);

            return 0;
        }
    }
}

Published 48 original articles · won praise 0 · Views 306

Guess you like

Origin blog.csdn.net/weixin_46399138/article/details/105414052