Gym 100090D Insomnia
生活随笔
收集整理的這篇文章主要介紹了
Gym 100090D Insomnia
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
從 n 變到 1,有多少種方案?
打表記憶化。
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int n; 6 int dp[1000005]; 7 int dfs(int n) { 8 if(n==1) 9 return 1; 10 if(dp[n]>0) 11 return dp[n]; 12 int cnt=0; 13 for(int i=2;i<=n;i++) { 14 if(n%i==0) 15 cnt+=dfs(n/i); 16 } 17 return dp[n]=cnt; 18 } 19 20 int main() 21 { 22 memset(dp,0,sizeof(dp)); 23 scanf("%d",&n); 24 printf("%d\n",dfs(n)); 25 26 return 0; 27 } View Code?
轉載于:https://www.cnblogs.com/TreeDream/p/6686863.html
總結
以上是生活随笔為你收集整理的Gym 100090D Insomnia的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银联卡闪付免密限额升至1000元?你还蒙
- 下一篇: 招商银行财新传媒联名卡额度怎么查询 盘点