基础语言-题目64(鸡兔同笼)
来源:互联网 发布:ipadair2怎么卸载软件 编辑:程序博客网 时间:2024/05/22 14:29
主要的就是一个解决问题的思路
#include <stdio.h>#include <string.h>#include <math.h>#include <iostream>#include <string>#include <algorithm>using namespace std;int main (){int N;cin >> N;while (N--){int num_elements, num_foot;cin >> num_elements >> num_foot;double ans_rabbit = ceil ( (num_foot - 2 * num_elements) / 2.0 ); //注意ceil返回值是double型,但是输出的确实整形 double ans_chicken = ceil ( (4 * num_elements - num_foot) / 2.0 );//cout << "ans_chicken = " << ans_chicken << " " << "ans_rabbit = " << ans_rabbit << endl; if (ans_chicken + ans_rabbit == num_elements && ans_rabbit >= 0 && ans_chicken >= 0){cout << ans_chicken << " " << ans_rabbit << endl;}else{cout << "No answer" << endl;}}return 0;}
- 基础语言-题目64(鸡兔同笼)
- NYOJ 题目64 鸡兔同笼
- nyoj题目64:鸡兔同笼
- 南阳题目64-鸡兔同笼
- 题目64 鸡兔同笼
- 题目64-鸡兔同笼
- 南阳oj 题目64 鸡兔同笼
- 南阳OJ 题目64:鸡兔同笼
- 题目1155:鸡兔同笼
- 题目1155:鸡兔同笼
- 题目1155:鸡兔同笼
- 题目1155:鸡兔同笼
- 题目1155:鸡兔同笼
- 题目1155:鸡兔同笼
- C语言 百钱百鸡 鸡兔同笼
- 鸡兔同笼[题目不难,提醒自己注意细节!!!]
- 【鸡兔同笼 64】
- 64 鸡兔同笼
- 使用 eflash 工具升级Power固件
- UVa 111 - History Grading
- Android4.2
- 地理诗句谚语例析
- JavaScript之Cookie与表单验证
- 基础语言-题目64(鸡兔同笼)
- 国外GIS 网站 一网打尽
- 新月,上弦月,满月,下弦月的区别
- 修改默认调试器(以后会用到)
- 徘徊在IT边缘
- Centos 和 windows7 双系统设置默认启动系统
- ICCAVR 中存储空间的分配
- 如何在jsp页面中引入css样式表文件和javascript文件
- 26 个 jQuery使用技巧