当前位置:网站首页>[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))
边栏推荐
- JS conversion of letters and numbers
- Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load
- How does the trading platform for speculation in spot gold ensure capital security?
- Code for generating test and training sets
- 如果辨别我现在交易的外盘股指期货交易平台是否正规安全?
- Global and Chinese markets for advanced wound care 2022-2028: Research Report on technology, participants, trends, market size and share
- Stc89c52/90c516rd/89c516rd DHT11 temperature and humidity sensor drive code
- Auto.js学习笔记15:autojs的UI界面基础篇2
- X Book 6.97 shield unidbg calling method
- Huawei interview question: divide candy
猜你喜欢

1148_ Makefile learning_ Targets, variables, and wildcards in makefile

An article to get you started VIM

Usage record of unity input system (instance version)

Stc89c52/90c516rd/89c516rd ADC0832 ADC driver code

第2章 控制结构和函数(编程题)

Use of foreach in QT

HOOK Native API

Chapter 2 control structure and function (programming problem)

Laravel9 local installation
![[ten minutes] manim installation 2022](/img/54/7b895d785c7866271f06ff49cb20aa.png)
[ten minutes] manim installation 2022
随机推荐
Auto.js学习笔记15:autojs的UI界面基础篇2
专升本语文资源整理
Is the largest layoff and salary cut on the internet coming?
C [advanced] C interface
WPF initialized event in The reason why binding is not triggered in CS
Reasons for MySQL master-slave database synchronization failure
Use of foreach in QT
【力扣刷题总结】数据库题目按知识点分类总结(持续更新/简单和中等题已完结)
Mysql性能优化(5):主从同步原理与实现
How to realize remote collaborative office, keep this strategy!
JS 字母和数字的相互转换
Global and Chinese market for nasal drug delivery devices 2022-2028: Research Report on technology, participants, trends, market size and share
JS conversion of letters and numbers
设备驱动程序的原理
Utilisation de foreach en Qt
如果辨别我现在交易的外盘股指期货交易平台是否正规安全?
Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load
专升本高数(四)
Laravel9 local installation
【笔记】AB测试和方差分析