当前位置:网站首页>[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))
边栏推荐
- 124 articles in total! Motianlun "high availability architecture" dry goods document sharing (including Oracle, mysql, PG)
- OP diode limit swing
- 4-4 beauty ranking (10 points)
- Global and Chinese markets for active transdermal drug delivery devices 2022-2028: Research Report on technology, participants, trends, market size and share
- MySQL + JSON = King fried
- What are the defaults for Binding. Mode=Default for WPF controls?
- X Book 6.97 shield unidbg calling method
- How to view Tencent's 2022 school recruitment salary, the total contract of cabbage is 40W?
- Huawei interview question: tall and short people queue up
- Ubuntu20.04 PostgreSQL 14 installation configuration record
猜你喜欢
![C # [advanced part] C # multithreading](/img/16/2a7c477b4cee32d9ce1e543c9d4c7e.png)
C # [advanced part] C # multithreading

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

实用调试技巧

Reasons for MySQL master-slave database synchronization failure

MySQL performance optimization (5): principle and implementation of master-slave synchronization

Hudi record

Redis中的SDS理解

How to view Tencent's 2022 school recruitment salary, the total contract of cabbage is 40W?

产品思维 | 无人机快递的未来值得期待吗?

hudi记录
随机推荐
MySQL performance optimization (5): principle and implementation of master-slave synchronization
如果辨别我现在交易的外盘股指期货交易平台是否正规安全?
【筆記】AB測試和方差分析
What are the defaults for Binding. Mode=Default for WPF controls?
[QT] QMap使用详解
Personal PC installation software
Huawei interview question: tall and short people queue up
共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)
Redis在windows系统中使用
1151_ Makefile learning_ Static matching pattern rules in makefile
Hash design and memory saving data structure design in redis
LitJson解析 生成json文件 读取json文件中的字典
实用调试技巧
Reasons for MySQL master-slave database synchronization failure
【常见问题】页面跨域和接口跨域
Utf8 error in Oracle migration of Jincang Kingbase database
Tidb 6.0: making Tso more efficient tidb Book rush
Principle of device driver
C [advanced] C interface
Auto.js学习笔记15:autojs的UI界面基础篇2