Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Home work:

Competitive Programming
Sistem dan Tekonologi informasi

1
Nama:Bagas Triambodo
Nrp:5116100082
PANDAOJ

1)JC12C - EZ Problem
Memory Limit: 32 MB
Time Limit: 2000 ms

Problem:
f(x) = f(1) + f(2) + f(3) + ... + f(x-2) + f(x-1)
f(1) = M

Find the value of f(1) + f(2) + f(3) + ... + f(2N+1)

Algoritma:
f(1)=m
f(2)=m
f(3)=f(1)+f(2)=m+m
f(4)=f(3)+f(2)+f(1)=2m+m+m
f(5)= f(4)+f(3)+f(2)+f(1)=4m+2m+m+m
f(6)= f(5)+f(4)+f(3)+f(2)+f(1)=8m+4m+2m+m+m
……..
f(n)=2n-2m

generalisasi:
f(1)+f(2)+….+ f(2n+1)+f(2n+2)=22n.m

2
Source Code:

You might also like