Files
python/TangDou/LuoGuBook/P4956.md
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

42 lines
823 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 题目分析
* 一年中有$52$个星期, $7 * 52 = 364$
* 星期一:$x$元
* 星期二:$x+k$
* 星期三:$x+2k$
* 星期四:$x+3k$
* 星期五:$x+4k$
* 星期六:$x+5k$
* 星期日:$x+6k$
* 目标是筹集$n$元
问题:$x$和$k$是怎么样来取值的?输出 $x$ **尽可能大**,$k$ **尽可能小的**。
$$1<=x<=100,k>=1$$
思考:
$$n=52\times (x+ (x+k) +(x+2k)+(x+3k)+(x+4k)+(x+5k)+(x+6k)) \\
\Leftrightarrow \\
n=52 \times (7x+21k)
$$
```c++
for(int x=100;x>=1;x--){
for(int k=1;52 * (7 * x + 21 * k) <= n;k++){
if(n==52*(7*x+21*k))
{
cout<<x<<endl;
cout<<k<<endl;
exit(0);
}
}
}
```
已知$x>=1,y>=1$,且$x+y=5$
问$x=?,y=?$
显然:$x<=4,y<=4$
$1<=x<=4,1<=y<=4$
(1)x=1,y=4
(2)x=2,y=3
(3)x=3,y=2
(4)x=4,y=1