Welcome   HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online
Home
FAQs
Problem Set
Practices
Online Contests
Major Exercises
OI Special
Judgement
Submit
Online Status
User Ranklist
Users
Register new
Login
Web Links
Hunan Normal University
College of Information Science and Engineering
有趣的数列
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 115, Accepted users: 112
Problem 10124 : No special judgement
Problem description
  有一具有20个元素的整形数列,且数列第1项的值为10,第2项的值为6,从数列的第3项开始,数列第k项的值=数列第(k-2)项的值-数列第(k-1)项的值,(i=3,4,....),请编写程序,从键盘输入k的值(1≤k≤20),求出数列array[k]的值。

Input
  输入一个正整数n(1≤n≤20),当输入的值为-1时,程序结束。

Output
  输出一个整数,表示数列第n项的值。

Sample Input
10
-1
Sample Output
-6
Judge Tips
  由题意可知本题的关键就是从第3项开始,每一项的值就是其前2项的值减去前1项的值。

Problem Source
  Teacher Llj 

Submit   Discuss   Judge Status  Problems  Ranklist 

HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online, Version 2010.5.5.final.
Web visits:2071 today,16258798 total, since 2010-05-07