|
|
|
|
背景 Background |
|
|
首届“科普杯”小学生网络程序设计邀请赛试题.
|
|
|
|
|
|
|
|
描述 Description |
|
|
加速等式(jsds.pas)
【问题描述】
已知s=2+2+3+5+8+12+17+...,求前n项时s的值。例如:n=4时,s=12;n=7时,s=49。
【输入文件】
只一行一个整数n(2<=n<=1000),表示前n项。
【输出文件】
只一行一个整数s,即数列前n项之和。
【输出样例】
输入:
7
输出:
49
【数据规模】
30%的数据,N<=10
50%的数据,N<=100
100%的数据,N<1000
|
|
|
|
|
|
|
|
输入格式 Input Format |
|
|
只一行一个整数n(2<=n<=1000),表示前n项。
|
|
|
|
|
|
|
|
输出格式 Output Format |
|
|
只一行一个整数s,即数列前n项之和。 |
|
|
|
|
|
|
|
时间限制 Time Limitation |
|
|
各个测试点1秒。
|
|
|
|
|
|
|
|
注释 Hint |
|
|
Free Pascal Code:
-------------------
program Plus;
var a,b:longint;
begin
readln(a,b);
writeln(a+b);
end.
C++ Code:
-------------------
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
}
|
|
|
|
|
|
|
|
|
Flag |
|
题号 |
P1038 |
|
其它 |
通过 |
55人 |
提交 |
119次 |
通过率 |
46% |
难度 |
0 |
|
|
|
|
|
|