| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

已结贴   问题点数：10  回复次数：6

men=男人数 women=女人数 child=小孩数

45

men=0 women=15 child=30
men=3 women=10 child=32
men=6 women=5 child=34
men=9 women=0 child=36

1

No solution!

得分:5

```#include<stdio.h>

int main()
{
int N;
int i,j,k;
int flag = 0;
scanf("%d", &N);
for(i=0; i<=N/3; i++){
for(j=0; j<=N/2; j++){
for(k=0; k<=N; k+=2){
if((i+j+k == N) && (3*i+2*j+k/2==N)){
flag =1;
printf("men=%d women=%d child=%d\n", i, j, k);
}
}
}
}
if(flag == 0) printf("No solution!\n");
return 0;
}```
得分:5

得分:0
5a+3b=45
2a+3(a+b)=45
2(2a+b)+(a+b)=45
(2a+b)+(3a+2b)=45

a=–45+3i

得分:0

b是(n–5a)/3
c是n-a–b
得分:0

```// a = +3*i-1*n, i>=(n+2)/3
// b = -5*i+2*n, i<=(2*n)/5
// c = +2*i+0*n, i>=0

#include <stdio.h>

int main( void )
{
unsigned n;
scanf( "%u", &n );

unsigned begin=(n+2)/3, end=(2*n)/5;
if( begin > end )
puts( "No solution!" );
else
{
for( unsigned i=begin; i<=end; ++i )
printf( "men=%u women=%u child=%u\n", +3*i-1*n, -5*i+2*n, +2*i+0*n );
}
}```
得分:0

3*men+2*women+0.5*child=45

• 7
• 1/1页
• 1

Powered by Discuz, Processed in 0.069927 second(s), 8 queries.