标签:href its ref show 输出 accept tput sample sed
http://acm.hdu.edu.cn/showproblem.php?pid=2501
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 9660 Accepted Submission(s): 7361
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int t; 6 scanf("%d",&t); 7 __INT64_TYPE__ dp[50]; 8 dp[1]=1; 9 dp[2]=3; 10 for(int i = 3 ; i <= 30 ; i++){ 11 dp[i]=dp[i-1]+dp[i-2]*2; 12 } 13 while(t--){ 14 int n; 15 scanf("%d",&n); 16 cout << dp[n] <<endl; 17 } 18 return 0; 19 }
http://acm.hdu.edu.cn/showproblem.php?pid=2190
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8584 Accepted Submission(s): 5692
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 __INT64_TYPE__ dp[35]; 5 dp[1]=1; 6 dp[2]=3; 7 for(int i = 3 ; i <= 30 ; i++){ 8 dp[i]=dp[i-1]+dp[i-2]*2; 9 } 10 int t; 11 scanf("%d",&t); 12 while(t--){ 13 int n; 14 scanf("%d",&n); 15 cout << dp[n] << endl; 16 } 17 return 0; 18 }
小结:找到当前状态由上几个状态的迭代方程注意避免重复计算即可。
标签:href its ref show 输出 accept tput sample sed
原文地址:https://www.cnblogs.com/MekakuCityActor/p/9189126.html