2677: Han Xin Dian Soldiers
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 708
Solved: 357
[
Submit][
Status][
Web Board]
Description
Liu Bang asked Han Xin: “How much do you think I can bring soldiers?” Han Xin: “At least 100,000.” Liu Bang asked: “What about you?” Han Xin said proudly: “The more the better, the better, the better! “Liu Bang was half -joking and said,” Then I can’t beat you? “Han Xin said:” No, the protagonist is a talent who controls the general, not to control the soldiers, but the generals are specially trained soldiers. It took 15,000 soldiers to fight on the battlefield. Unfortunately, some soldiers were killed, but the specific figures were unknown, but Han Xin was very smart. He asked the soldiers (of course, a living soldier, excluding the soldier’s body). People, five people, there are four more people, seven people, and six more people. Then Han Xin knows about the number of war deaths. Then the question is now, please compile a simple program to calculate the possible possible programs. Number of soldiers;
Input
no input
Output
14896
14791
14686
14581
14476
14371
14266
.
.
.
.
.
HINT
Simply set an equation group (X represents the number of soldiers survival);
x=3*k+2;(k=0,1,2,3….)
x=5*t+4;(t=0,1,2,3…..)
x=7*s+6;(s=0,1,2,3…..)
AC code:
#include<stdio.h>
int main()
{
int i;
for(i=0; i<15000; i++)
if(i%3==2&&i%5==4&&i%7==6)
printf("%d\n",15000-i);
return 0;
}
As soon as I saw a question that I saw in OJ and C language. At that time, I gave up when I saw it completely. I just happened to see it. I just happened to see it. In fact, it was very simple.