本文主要是介绍幸运星数(爷再也不想用pow了),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
解法:
暴力
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'int main() {ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);int n;long long sum = 0, a;cin >> n;for (int i = 1; i <= n; i++) {a = 1;for (int j = 1; j <= i; j++) {a *= 2;}sum += a;}cout << sum << endl;return 0;
}
这篇关于幸运星数(爷再也不想用pow了)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!