Logo
(追記) (追記ここまで)

5346번 - Frodo Sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB20913812567.204%

문제

The Fibonacci sequence is a famous integer sequence defined by Leonardo of Pisa in 1202. The sequence is defined as follows:

  • Fib1 = 1
  • Fib2 = 1
  • Fib3 = 2
  • Fib4 = 3
  • Fib5 = 5
  • Fibn = Fibn-1 + Fibn-2 for all n>2

What you may not know is that Frodo of Bag End also defined an integer sequence called the Frodo sequence. Frodo’s sequence is defined as follows:

  • Fro1 = 1
  • Fro2 = 1
  • Fro3 = 2
  • Fro4 = 2
  • Fro5 = 3
  • Fron = Fron-1 + Fron-2 - Fron-3 for all n>3

You need to write a program that given n finds Fron.

입력

he input will be a sequence of integers, one per line. The end of input will be signaled by the integer 0. All integers, other than the last (zero), are positive and less than 231.

출력

For each positive integer, n, print Fron.

제한

예제 입력 1

2
4
5
6
0

예제 출력 1

1
2
3
3

힌트

출처

School > PLU High School Programming Contest > PLU 2013 > Novice 11번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /