韩信点兵

来源:互联网 发布:bbs网络上什么意思 编辑:程序博客网 时间:2024/06/05 20:14


让士兵先后以三人一排,五人一排,七人一排的变换队形。已知总人数不超过100并且大于10人。

输入:

 2 1 6
 2 1 3 
输出:

Case 1:41 
Case 2:NO Answer


#include <stdio.h>int main(){#ifdef LOCALfreopen("in.txt","r",stdin);freopen("out.txt","w",stdout);#endifint a,b,c,n=0;int x;//总人数while(scanf("%d%d%d",&a,&b,&c)==3){++n;for(x = 10;x <= 100;x++)if(x%3==a&&x%5==b&&x%7==c)printf("Case %d: %d\n",n,x);}printf("Case %d:No answer\n",n);return 0;}


0 0