[HDU] [2045] Not Easy Series (3) - LELE's RPG Problem

Problem Description

Loading...

Problem Analysis

A pattern-finding problem straight out of high school…
Just work it out with permutations and combinations.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<math.h>
int main() {
	__int64 t,r;
	int n,i;
	while(scanf("%d",&n)!=EOF) {
		if(n==1)
			printf("3\n");
		else if(n==2)
			printf("6\n");
		else {
			for(t=6,i=2; i<n; i++) {
				r=3*pow(2,i)-t;
				t=r;
			}
			printf("%I64d\n",r);
		}
	}
	return 0;
}

Loading...