【杭电】[2045]不容易系列之(3)——LELE的RPG难题

文章字数:77

问题描述

问题分析

高中的找规律的题……
用排列组合算就好

 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;
}

该内容采用 CC BY-NC-SA 4.0 许可协议。

如果对您有帮助或存在意见建议,欢迎在下方评论交流。

加载中...