当前位置:网站首页>1141: C语言训练-百钱百鸡问题_剪枝循环
1141: C语言训练-百钱百鸡问题_剪枝循环
2022-04-21 20:37:00 【这题ac再睡】
题目 1141: C语言训练-百钱百鸡问题
时间限制: 1Sec 内存限制: 128MB 提交: 6252 解决: 3572
题目描述
中国古代数学家张丘建在他的《算经》中提出了著名的“百钱买百鸡问题”:鸡翁一,值钱五,鸡母一,值钱三,鸡雏三,值钱一,百钱买百鸡,问翁、母、雏各几何?
输入
无输入
输出
给出所有的解,每组解占一行
解的顺序:按“字典序”排列,即公鸡数少的在前;公鸡数相同,母鸡数少的在前
格式:
cock=%d,hen=%d,chicken=%d\n
样例输入
无
样例输出
cock=0,hen=25,chicken=75
cock=4,hen=18,chicken=78
cock=8,hen=11,chicken=81
cock=12,hen=4,chicken=84
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,k;
for( i=0;i<=100/5;i++ )
{
for( j=0;j<=100/3;j++ )
{
k=100-i-j;
if( k%3 ) continue;
if( 5*i+3*j+k/3==100 )
cout<<"cock="<<i<<",hen="<<j<<",chicken="<<k<<endl;
}
}
return 0;
}
版权声明
本文为[这题ac再睡]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_63173957/article/details/124326335
边栏推荐
猜你喜欢

Android Development Internship interview questions, Android development interview basis

How to ensure the stability and correctness of API? That's all you need

【网络安全】红队渗透项目之Stapler1(下)

【Azure 应用服务】Azure Function 启用 Managed Identity后, Powershell Funciton出现 ERROR: ManagedIdentityCredential authentication failed

Redis Foundation

制造业数字化转型后发展的未来画像

无人机组装调试教程

《ROS2机器人建模URDF》8.2RVIZ2可视化移动机器人模型

2022-4-11至2022-4-17周报

How to make join run faster? (book at the end of the text)
随机推荐
Andorid -- why use transactions? What is transaction commit and rollback?
The whole process of callback registration and callback of openharmony sensor module
Deploying redis in Linux Environment
IoT平台如何实现业务配置中心
C# 双保险进程监视器 lol 保证被监视的程序'几乎'永远运行. 关键字:进程操作 进程查看 创建进程
Go语言自学系列 | golang类型定义和类型别名
Actual combat | performance pressure test of JMeter typical e-commerce scenario (order / payment)
[system analyst's road] real topic of system analyst's paper writing in the next 2020
华融融达期货这家公司怎么样?期货开户办理安全吗?
Data preprocessing for data analysis
Specific methods of configuring Profibus and PROFINET communication in two TIA botu projects
[network security] stapler1 of red team penetration project (Part 2)
Debugging MS source code
php处理视频ffmpeg(转)
复线性空间与复结构
Apache 启动不成功,MySQL登录权限问题,排查方法
RTMP(3):Protocol Control Message
Go语言自学系列 | golang defer语句
C package DLL into program
神经网络 || 注意力机制的Pytorch代码实现