| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 21867 | Accepted: 9767 | 
Description
Input
Output
Sample Input
1 2 9 0
Sample Output
1 2 10
Source
AC代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int n;
    char s1,s2;
    int dp[6000],i;
    dp[1]=1;
    i=2;
    int two=1,three=1,five=1,t1,t2;
    while(i<=5842){
        dp[i]=min((t1=min(2*dp[two],3*dp[three])),5*dp[five]);
        if(dp[i]==dp[two]*2)two++;
        if(dp[i]==dp[three]*3)three++;
        if(dp[i]==dp[five]*5)five++;
        i++;
    }
    while(cin>>n&&n){
        cout<<dp[n]<<'\12';
    }
    return 0;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/zp___waj/article/details/47302127