HDU-2042 不容易系列之二
HDU-2042 不容易系列之二

代码

#include <iostream>

using namespace std;

int main() {
	int n;
	cin>>n;
	for(int i=0; i<n; i++) {
		int station;
		cin>>station;
		int ans = 3;
		while(station>=1) {
			ans = (ans-1)*2;
			station--;
		}
		cout<<ans<<endl;
	}
	return 0;
}

注解

1、简单的递推关系。
2、正确使用循环结构,终止条件要正确。

结果

HDU-2042 不容易系列之二

相关文章:

  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-06-17
  • 2021-09-18
猜你喜欢
  • 2021-06-19
  • 2022-12-23
  • 2021-06-06
  • 2021-05-25
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
相关资源
相似解决方案