1193分数序列求和
来源:互联网 发布:数据库 offset 编辑:程序博客网 时间:2024/05/21 10:37
分数序列求和
Time Limit:1000MS Memory Limit:65536K
Total Submit:1199 Accepted:633
Description
有一个分数序列:2/1,3/2,5/3,8/5,13/8,21/13,….求这个数列前n项之和。
Input
输入一个整数n ( 1 <= n <= 40 )
Output
一个实数(前n项的和),保留两位小数
Sample Input
3
Sample Output
5.17
Source
#include <stdio.h>/*2 3 5 8 13 21 1 2 3 5 8 13*/int main(){ int n; scanf("%d",&n); double a[n+1]; int i; double sum=0; a[1]=1; a[2]=2; for(i=3;i<=n+1;i++) { a[i]=a[i-1]+a[i-2]; } for(i=1;i<=n;i++) { sum+=a[i+1]/a[i]; } printf("%.2lf",sum); return 0;}
阅读全文
1 0
- 1193分数序列求和
- 分数序列求和
- 分数序列规律求和
- 第八周 OJ 分数序列求和
- 第八周—OJ分数序列求和
- 第八周-OJ-B分数序列求和
- 分数求和
- 分数求和
- 分数求和
- 分数求和
- 分数求和
- 分数求和
- 分数求和
- 分数求和
- 求分数序列和:int求和,小心溢出
- 分数序列
- 分数序列
- 分数序列
- 第十一周项目4
- uavcan扩展帧格式
- 解决Windows资源管理器右键菜单打开EditPlus容易导致资源管理器无响应问题
- @SpringApplicationConfiguration(classes = Application.class) 报错,注解不能导入。
- 详解tomcat的连接数与线程池
- 1193分数序列求和
- UIAutomator2.0详解(UIDevice篇----截屏)
- 面向对象进阶 01 对象、类、属性,方法、命名空间
- 欢迎使用CSDN-markdown编辑器
- WSGI的“前世今生”
- Android 教程
- Bootstrap 浏览器/设备支持
- react native之原生和RN的交互
- SQL 性能分析器 SQL Performance Analyzer SPA