1995 汉诺塔V
作者:互联网
http://acm.hdu.edu.cn/showproblem.php?pid=1995
找规律:
需要注意的是:
最后输出的结果超出了int的范围 所以 要用long long 来定义
Code
1 #pragma warning(disable:4996) 2 3 //#define _CRT_SECURE_NO_WARNINGS 4 5 #include<stdio.h> 6 #include<stdlib.h> 7 #include<string.h> 8 #include<algorithm> 9 #include<iostream> 10 using namespace std; 11 12 int main() 13 { 14 int T; 15 int N, K; 16 long long sum; 17 scanf("%d", &T); 18 while(T--) 19 { 20 sum = 1; 21 scanf("%d %d", &N, &K); 22 for (int i = 0; i < N - K; i++) 23 { 24 sum *= 2; 25 } 26 cout << sum << endl; 27 } 28 return 0; 29 }
标签:1995,int,sum,long,汉诺塔,include,scanf 来源: https://www.cnblogs.com/CheeseIce/p/10804778.html