当前位置:网站首页>Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
2022-07-06 14:42:00 【No two or three things】
experiment 4-1-10 The problem of rabbit reproduction
fraction 15
Full screen browsing topics
Switch layout
author Xu Jingchun
Company Zhejiang University
A couple of Rabbits , From the day after birth 3 A couple of rabbits are born every month from . The little rabbit grows to the third place 3 Two months later, a couple of rabbits were born every month . If the rabbits don't die , May I ask 1 A pair of rabbits born six months ago , It will take at least a few months for the total number of rabbits to reach N Yes ?
Input format :
The input gives no more than 10000 The positive integer N.
Output format :
Output the total number of rabbits in one line to N Minimum number of months required .
sample input :
30
sample output :
9
Code length limit
16 KB
The time limit
400 ms
Memory limit
64 MB
Code implementation :
# include <stdio.h>
main() {
int N;
scanf("%d",&N);// 1,1,2,3 Satisfy Fibonacci sequence
int a = 1,b = 1,max = 1,temp,month = 1;
if (N == 1) {
printf("%d",month);
}else {
month = 2;
while(max < N) {
temp = a;
a += b;
b = temp;
max = (a >= b) ? a : b;
month += 1;
}
printf("%d",month);
}
return 0;
}
边栏推荐
- 安全面试之XSS(跨站脚本攻击)
- The most popular colloquial system explains the base of numbers
- Hcip -- MPLS experiment
- Four methods of exchanging the values of a and B
- Captcha killer verification code identification plug-in
- 《統計學》第八版賈俊平第七章知識點總結及課後習題答案
- 移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
- [pointer] find the value of the largest element in the two-dimensional array
- 1.支付系统
- Uibutton status exploration and customization
猜你喜欢
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
JDBC事务、批处理以及连接池(超详细)
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Library management system
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
Data mining - a discussion on sample imbalance in classification problems
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
1.支付系统
随机推荐
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Network technology related topics
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
Four methods of exchanging the values of a and B
What language should I learn from zero foundation. Suggestions
Get started with Matplotlib drawing
函数:求方程的根
王爽汇编语言学习详细笔记一:基础知识
5 minutes to master machine learning iris logical regression classification
【指针】删除字符串s中的所有空格
Pointer -- eliminate all numbers in the string
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
Record an edu, SQL injection practice
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?
王爽汇编语言详细学习笔记二:寄存器
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
关于超星脚本出现乱码问题
[pointer] use the insertion sorting method to arrange n numbers from small to large
浙大版《C语言程序设计实验与习题指导(第3版)》题目集