当前位置:网站首页>[punch in - Blue Bridge Cup] day 1 --% 7F format output
[punch in - Blue Bridge Cup] day 1 --% 7F format output
2022-06-30 03:35:00 【M4chael1】
subject 1
Based on practice A+B problem
The first line of input contains two integers , Separated by spaces , respectively A、B.
Output one line , Include an integer , Express A+B Value .
Ideas
Use... After input
splitDivision
Code
a, b = map(int, input().split())
print(a+b)
subject 2
Based on practice Fibonacci The sequence
Fibonacci The recurrence formula of sequence is :Fn=Fn-1+Fn-2, among F1=F2=1.
When n The larger the ,Fn It's also very large. , Now we want to know ,Fn Divide 10007 What is the remainder of .
Input contains an integer n.
Output one line , Contains an integer , Express Fn Divide 10007 The remainder of .
Ideas
With iteration seek Fn after , Remainder
The test case has reached 999999 了 , Even the Fibonacci sequence stored in array can not reach the time and space specified in the topic , and fib(n) Will be very long ,long long int It can not meet the accuracy requirements , So we must change our thinking .
Because our answer is the most important remainder 10007, This number is less than 10007 when , That's the number . If it is greater than 10007, We can take the balance directly 10007, It has no effect on the final result .
————————————————
Copyright notice : This paper is about CSDN Blogger 「 Hard to learn 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/qq_43656233/article/details/105062582
Code
f1=f2=1
fn=0
n = int(input())
if n == 1 or n == 2:
print(1)
elif n > 2:
for i in range(3, n+1):
fn = (f1 + f2) % 10007
f1 = f2
f2 = fn
print(fn)
subject 3
Based on practice Area of circle
Radius of given circle r, Find the area of a circle .
Input contains an integer r, Represents the radius of a circle .
Output one line , Contains a real number , Round to decimal 7 position , Represents the area of a circle .
Their thinking
The formula Π r^2, Note the output format
Code
PI=3.14159265358979323
r = int(input())
area = PI*r*r
print('%.7f' % area)
subject 4
Based on practice Sum a sequence
seek 1+2+3+…+n Value .
Input includes an integer n.
Output one line , Include an integer , Express 1+2+3+…+n Value .
Their thinking
The mathematical formula :(n+1)*n/2
Code
n = int(input())
sum = n*(1+n)/2
print(int(sum))
边栏推荐
- 【笔记】2022.6.7 数据分析概论
- Data set preparation and arrangement
- Code for generating test and training sets
- Personal PC installation software
- Gulang bilibilibili Live Screen Jackie
- Half a year after joining the company, I was promoted to a management post
- Redis is used in Windows system
- Learning cyclic redundancy CRC check
- X Book 6.89 shield unidbg calling method
- Possible problems in MySQL cross database operation with database name
猜你喜欢

Buffer pool of MySQL notes

X书6.97版本shield-unidbg调用方式

X书6.89版本shield-unidbg调用方式

Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load

LitJson解析 生成json文件 读取json文件中的字典

Arrangement of language resources of upgraded version

The broadcast module code runs normally in autojs4.1.1, but an error is reported in pro7.0 (not resolved)

数据库的下一个变革方向——云原生数据库

Auto. JS learning notes 16: save to the mobile phone by project, instead of saving a single JS file every time, which is convenient for debugging and packaging

golang bilibili直播弹幕姬
随机推荐
The 5-year Android development interview took 20 days to join Alibaba
产品思维 | 无人机快递的未来值得期待吗?
Use of foreach in QT
Feign pit
Installation and use of yarn
专升本高数(三)
Gulang bilibilibili Live Screen Jackie
Code for generating test and training sets
图的邻接矩阵存储 C语言实现BFS
【筆記】AB測試和方差分析
MySQL performance optimization (5): principle and implementation of master-slave synchronization
如何实现远程协同办公,收好这份攻略!
QT中foreach的使用
【常见问题】页面跨域和接口跨域
Stc89c52/90c516rd/89c516rd ADC0832 ADC driver code
Some common functions and precautions
Global and Chinese market of ULTRACENTRIFUGES 2022-2028: Research Report on technology, participants, trends, market size and share
Huawei interview question: divide candy
How do college students make money by programming| My way to make money in College
Are you a "social bull" or a "social terrorist" in the interview?