Skip to content

Commit

Permalink
韩信点兵
Browse files Browse the repository at this point in the history
  • Loading branch information
muscle committed Jul 30, 2015
1 parent f00c33b commit eada606
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 习题2-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//习题2-2
//韩信点兵
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
freopen("input.txt","r",stdin);

int a,b,c;
int n; //总人数 10<=n<=100
int min;
int count=1;
int flag=0; //有无解的旗帜

while(cin>>a>>b>>c)
{
flag=0;
for(int i=10; i<=100; i++)
{
if(i%3==a&&i%5==b&&i%7==c)
{
flag=1; //有解
min=i;
break;
}
}

if(flag) cout<<"Case "<<count<<": "<<min<<endl;
else cout<<"Case "<<count<<": No answer"<<endl;
count++;
}
return 0;
}

0 comments on commit eada606

Please sign in to comment.