Code Monkey home page Code Monkey logo

Comments (4)

kengwang avatar kengwang commented on June 15, 2024

可以只列举7的倍数哦!然后再根据条件还原为测试人数,之后再判断是否符合其他条件
Example见下:

#include <stdio.h>
int main(){
	int a,b,c,kase=0,hasans=0;
	while(scanf("%d %d %d",&a,&b,&c)==3){
		//这边我们边读入边计算 
		for (int i=14;i<=93;i=i+7){//列举7的倍数 
			int person=i+c;//猜测的总人数 
			if (person%3==a && person%5==b){//判断是否符合先前的条件 
				printf("Case %d: %d\n",++kase,person);//输出结果 
				hasans=1;//找到结果 
				break;//结束列举7倍数 
			}			
		} 
		if (!hasans){
				printf("Case %d: No answer\n",++kase);//输出结果 
			} 
			hasans=0;
	}
	
	return 0;
}

from aoapc-bac2nd.

Coder6886 avatar Coder6886 commented on June 15, 2024

@kengwang
你没有考虑到人数在10到13之间的情况,如:Case1:1 0 3 是10,但是思路挺好。

from aoapc-bac2nd.

kengwang avatar kengwang commented on June 15, 2024

@kengwang
你没有考虑到人数在10到13之间的情况,如:Case1:1 0 3 是10,但是思路挺好。

感谢指出

from aoapc-bac2nd.

3099462480 avatar 3099462480 commented on June 15, 2024

#include<stdio.h>
int main(){
int a,b,c,n;
while(scanf("%d%d%d",&a,&b,&c)==3){
for(n=10;n<=100;n++){
if(n%3==a&&n%5==b&&n%7==c){
printf("%d\n",n);
break;
}
}
if(n==101){printf("No answer");}
}
return 0;
}

from aoapc-bac2nd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.