哈哈哈天蝎


私信TA

用户名:li1234567890

访问量:5372

签 名:

li1234567890

等  级
排  名 401
经  验 4910
参赛次数 7
文章发表 12
年  龄 0
在职情况 学生
学  校 贺州学院
专  业 软件工程

  自我简介:

解题思路:规律 2 * (2 ^n - 1)

注意事项:数据比较大,有一部分会超 long long ,用模拟

参考代码:

#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int num[205] = { 1 };
int my_pow(int n,int k)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < k; j++)
			num[j] *= 2;
		for (int j = 0; j < k; j++)
		{
			if (num[j] >= 10)
			{
				num[j + 1]++;
				num[j] -= 10;
			}
		}
		if (num[k]) k++;
	}
	return k;
}
void print(int k)
{
	for (int i = k - 1; i >= 0; i--)
		cout << num[i];
	cout << endl;
}
int main()
{
	int n;
	cin >> n;
	int k = my_pow(n, 1);
	num[0]--;
	k = my_pow(1, k);
	print(k);
	//cout << "k = " << k << endl;
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区