TREEBONACCI - Threebonacci

no tags 

A number belongs to Threebonacci sequence if it belongs to Fibonacci (consider 1 as being the first number in this sequence) sequence and satisfy at least one criteria below:

  1. The number representation contains at least one digit 3.
  2. The number is a multiple of 3.

Input

Each test case contains an integer N (1 ≤ N ≤ 60). Input ends with EOF.

Output

For each test case print a single line containing the Nth term in Threebonacci sequence.

 

Example 1

Input:
1
3

Output:
3
21

hide comments
jrantor: 2020-12-10 20:51:10

I am getting WA, can I get some test cases?

[NG]: Use int64.

Last edit: 2020-12-11 14:43:32

Added by:Coach UTN FRSF
Date:2015-09-01
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY