zoukankan      html  css  js  c++  java
  • Ural 1073 Square Country (DP)

    题目地址:Ural 1073

    DP水题。也能够说是背包。

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <stdlib.h>
    #include <math.h>
    #include <ctype.h>
    #include <queue>
    #include <map>
    #include <set>
    #include <algorithm>
    
    using namespace std;
    const int INF=0x3f3f3f3f;
    #define LL long long
    int dp[60006];
    int main()
    {
        int i, j, n;
        memset(dp,INF,sizeof(dp));
        dp[0]=0;
        for(i=1;i<250;i++)
        {
            for(j=i*i;j<=60000;j++)
            {
                dp[j]=min(dp[j],dp[j-i*i]+1);
            }
        }
        while(scanf("%d",&n)!=EOF)
        printf("%d
    ",dp[n]);
        return 0;
    }
    


  • 相关阅读:
    64_q2
    64_q1
    64_p10
    64_p9
    64_p8
    64_p7
    64_p6
    64_p5
    64_p4
    64_p3
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/5135145.html
Copyright © 2011-2022 走看看