Topcoder Single Round Match 453.5 Round 1 - Division I, Level Two TheProduct
来源:互联网 发布:安卓应用推荐 知乎 编辑:程序博客网 时间:2024/05/17 23:23
平面图问题。考虑一张n个点E条边的平面图,当E达到最大值的时候,设有F个面,那么所有的有界面都是三角形。考虑一条边,他必然关联2个面,一个面又有3条边。有 F=2*E/3,由欧拉公式:V+F-E=2。则E=3*(V-2)。对于每一个V,E,算出价值V^3+E^2。跑一个完全背包就可以了。完全背包可见:背包九讲
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <map>#include <set>#include <queue>#include <cstdlib>#include <string>#include <vector>#define INF 1e9#define maxn 64using namespace std;bool vis[1000000];vector<int>a;int dp[50009];class PlanarGraphShop{public:int bestCount(int n){a.push_back(1);vis[1]=1;a.push_back(8);vis[8]=1;a.push_back(9);vis[9]=1;for(int i=3;i*i*i<=n;i++){for(int j=0;j<=3*(i-2);j++){if(i*i*i+j*j>n)break;if(!vis[i*i*i+j*j]){a.push_back(i*i*i+j*j);vis[i*i*i+j*j]=1;}}}dp[0]=0;for(int i=1;i<=n;i++) dp[i]=INF;for(int i=0;i<(int)a.size();i++){for(int j=a[i];j<=n;j++)dp[j]=min(dp[j],dp[j-a[i]]+1);}return dp[n];}};
0 0
- Topcoder Single Round Match 453.5 Round 1 - Division I, Level Two TheProduct
- topcoder Single Round Match 457 Round 1 - Division I, Level Two baTheHexagonsDivOne
- Member Single Round Match 461 Round 1 - Division I, Level Two BuildingCities
- Single Round Match 464 Round 1 - Division I, Level Two ColorfulDecoration
- Member Single Round Match 465 Round 1 - Division I, Level Two GreenWarfareze
- Member Single Round Match 474 Round 1 - Division I, Level Two TreesCount
- Single Round Match 477 Round 1 - Division I, Level Two PythTriplets
- Single Round Match 480 Round 1 - Division I, Level Two NetworkSecurity
- Single Round Match 479 Round 1 - Division I, Level Two TheAirTripDivOne
- Single Round Match 506 Round 1 - Division I, Level Two SlimeXGrandSlimeAuto
- Single Round Match 524 Round 1 - Division I, Level Two LongestSequence
- Single Round Match 573 Round 1 - Division I, Level Two SkiResorts
- Single Round Match 508 Round 1 - Division I, Level Two YetAnotherORProblem
- Single Round Match 517 Round 1 - Division I, Level Two AdjacentSwaps
- Single Round Match 462 Round 1 - Division I, Level Three WarTransportation
- Single Round Match 459 Round 1 - Division II, Level Three gaiParkAmusement
- Single Round Match 671 Round 1 - Division II, Level Three(状压DP)(略难)
- 2010 TCO Algorithm Online Round 5 - Division I, Level Two LongJourney
- 高仿新闻教程--新闻Item的布局复习(3)
- 使用回调方式写POI导入excel工具类
- Program work 4. Infix expression convert to Prefix expression (Ⅰ)
- 使用回调方式写POI导入excel工具类
- STL提供了三个最基本的容器:vector,list,deque
- Topcoder Single Round Match 453.5 Round 1 - Division I, Level Two TheProduct
- 使用回调方式写POI导入excel工具类
- 在真机上调试Android应用程序(图文详解)
- 使用回调方式写POI导入excel工具类
- 使用回调方式写POI导入excel工具类
- C ch13重點整理-Pointer
- 利用IntentService实现在broadcastreceiver中比较耗时的任务
- 医学图像处理开源软件
- 今天开始第一篇博客!