White algorithm - Simple Plan

Recent stay home, has been playing with the city skyline, and then find how to control population education constitute a problem.

Question A:

对于给定的人口数据N(2^31-1>N>9),求出应该建立多少个A(小学),B(中学),C(大学)才能满足给定的比例(人口文化教育构成)
已知A单个容量为:300
已知B单个容量为:1000
已知C单个容量为:4500

Conditional A:

Mon 06 未受教育40% 小学教育30% 中学教育20% 大学教育10% 受教育程度 人口文化教育构成

Example:

输入:13520
输出:27,5,1

Note: only finished primary school before they can read, before they can finish high school to university.


With code:

#include <iostream>
#include <stdio.h>
#include <math.h>

int main()
{
	int N,temp,a=0,b=0,c=0;
	float A, B, C;
	scanf_s("%d", &N);
	temp = floor(N / 10);
	for (a = 0; temp > a * 50; a++);
	for (b = 0; temp * 3 > b * 1000; b++);
	for (c = 0; temp > c * 4500; c++);
	printf("%d,%d,%d", a,b,c);
	return 0;
}

But in fact this is not consistent with the laws of the game, a 1w + urban population, to build more than 20 primary school? Budget is absolutely not enough, completing construction of what it once was, so we introduced the following conditions:

Conditional B:

Building Type Construction costs Maintenance costs capacity
primary school $10000 $ 160 / week 300 people
High school $24000 $ 560 / week 1000
the University $75000 $ 1920 / week 4500 people

Problem B:

对于给定的人口数据N(2^31-1>N>9),一定时间T(T>3周),求出在T时间内应该建立多少个A(小学),B(中学),C(大学)才能满足给定的比例且花费最少(人口文化教育构成)。
注:学生的课程周期为一周,且不计建筑时间。

To be continued ...

Published 11 original articles · won praise 8 · views 3271

Guess you like

Origin blog.csdn.net/weixin_44076906/article/details/104233109