Comments (4)
可以只列举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.
@kengwang
你没有考虑到人数在10到13之间的情况,如:Case1:1 0 3 是10,但是思路挺好。
from aoapc-bac2nd.
@kengwang
你没有考虑到人数在10到13之间的情况,如:Case1:1 0 3 是10,但是思路挺好。
感谢指出
from aoapc-bac2nd.
#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)
- Uva的链接失效
- 第一章習題答案
- 第一,二章习题代码在这里~ HOT 1
- 第二版p269 Uva1347图9-4(a)情况不可能出现?
- uva注册不了,无法收到注册邮件,已经换了三个邮箱了. HOT 2
- 程序3-7 回文词 HOT 1
- 为什么例题提交时常会出一些问题?
- 例题7-8 (UVa 10603) 正确性
- 例题7-13 UVa1374猜想
- 第5章 字符串 部分有问题
- 例题9-15 s1和s2的计算可简化
- 表10-5第四列问题
- 勘误
- ch9 UVa1218 程序正确性存在问题 HOT 2
- Considerable Optimization in Page 193, Chapter 7 (ch7/queen2.cpp)
- 例题9-18 跳舞机 UVa10618翻译有误P291
- 第二版第二章正文表述有误
- 例题6-20,uva1599是不是有一行多余代码?
- UVA网站太慢了吧,有什么可以替代的方法吗 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aoapc-bac2nd.