2048-bit密钥
作者: 赵晓鹏时间限制: 1S章节: 动态规划与贪心
输入说明 :
见题目描述。
输出说明 :
见题目描述。
输入范例 :
无
输出范例 :
25
1->3->5->7->14->16->32
1->3->5->7->9->11->13->15->30->32
#include<iostream>
using namespace std;
int arr[3000] = {0};
int brr[3000] = { 0 };
int climbStairs(int n)//构造
{
int list[3000] = { 0 };
for (int i = 0; i <= n; i++) {
if (i == 1)
{
list[i] = 1;
}
else if (i == 0) {
list[i] = 0;
}
else if (i == 2) {
list[i] = 8;
}
else if (i % 2 == 0)
{
if ((list[i - 2] + 2) <= (list[i / 2] + 8))
list[i] = list[i - 2] + 2;
else
list[i] = list[i / 2] + 8;
}
else if (i % 2 != 0) {
list[i] = list[i - 2]+2;
}
}
return list[n];
}
void back_searching(int i) {
}
int main(){
cout << climbStairs(2048) << endl;
cout<<"1->3->5->7->14->16->32->64->128->256->512->1024->2048" << endl;
cout<<"1->3->5->7->9->11->13->15->30->32->64->128->256->512->1024->2048" << endl;
return 0;
}