ZOJ 3648 Gao the Grid II
2012-10-01 17:01
381 查看
还是dp。。。比较恶心
注释掉的那个是暴力程序。。找错用的
注释掉的那个是暴力程序。。找错用的
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<queue> #include<stack> #include<string> #include<map> #include<set> #include<cmath> #include<cassert> #include<cstring> #include<iomanip> using namespace std; #ifdef _WIN32 #define i64 __int64 #define out64 "%I64d\n" #define in64 "%I64d" #else #define i64 long long #define out64 "%lld\n" #define in64 "%lld" #endif /************ for topcoder by zz1215 *******************/ #define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++) #define FFF(i,a) for( int i = 0 ; i < (a) ; i ++) #define FFD(i,a,b) for( int i = (a) ; i >= (b) ; i --) #define S64(a) scanf(in64,&a) #define SS(a) scanf("%d",&a) #define LL(a) ((a)<<1) #define RR(a) (((a)<<1)+1) #define pb push_back #define CL(Q) while(!Q.empty())Q.pop() #define MM(name,what) memset(name,what,sizeof(name)) #define MC(a,b) memcpy(a,b,sizeof(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define read freopen("in.txt","r",stdin) #define write freopen("out.txt","w",stdout) const int inf = 0x3f3f3f3f; const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL; const double oo = 10e9; const double eps = 10e-9; const double pi = acos(-1.0); const int maxn = 101; i64 dp[maxn][maxn]; i64 a[maxn][maxn]; i64 s[maxn][maxn]; i64 b[maxn][maxn]; i64 sb[maxn][maxn]; bool can(int x,int y,int _x,int _y) { int dx,dy; dx = _x-x; dy = _y-y; if(dx*(-x)+dy*(-y)<=0) { return false; } if(dx*_x+dy*_y<=0) { return false; } if(x*_x+y*_y<=0) { return false; } return true; } void init() { MM(a,0); MM(dp,0); MM(s,0); MM(b,0); MM(sb,0); int temp,t2; for(int i=2;i<maxn;i++) { for(int j=2;j<maxn;j++) { temp=0; t2=0; for(int x=0;x<i;x++) { for(int y=0;y<j;y++) { if(can(x,j,i,y)) { temp++; if(y&&x) { t2++; } } } } b[i][j]=t2; a[i][j]=temp; } } for(int i=2;i<maxn;i++) { for(int j=2;j<maxn;j++) { s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j]; } } for(int i=2;i<maxn;i++) { for(int j=2;j<maxn;j++) { sb[i][j]=sb[i-1][j]+sb[i][j-1]-sb[i-1][j-1]+b[i][j]+b[j][i]; } } for(int i=2;i<maxn;i++) { for(int j=2;j<maxn;j++) { dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+2*s[i][j]+sb[i][j]; } } return ; } int n,m; /* int find() { int ans=0; for(int i=0;i<=n;i++) { for(int j=0;j<=m;j++) { for(int a=0;a<=n;a++) { for(int b=0;b<=m;b++) { for(int x=0;x<=n;x++) { for(int y=0;y<=m;y++) { if(can(x-i,y-j,a-i,b-j)) { ans++; } } } } } } } ans/=6; return ans; } */ int main() { init(); while(cin>>n>>m) { cout<<dp [m]<<endl; // cout<<find()<<endl; } return 0; }
相关文章推荐
- [报告]ZJU 3648 Gao the Grid II
- Zoj 3535 Gao the String II (AC自动机+dp)
- zoj 3647 Gao the Grid
- Zoj 3647 Gao the Grid (数论?)
- ZOJ 3647 Gao the Grid
- zoj 3647 Gao the Grid (求三角形的个数,困难)
- Zoj 3535 Gao the String II (AC自己主动机+dp)
- zoj 3535 Gao the String II (ac自动机+dp)
- ZOJ 3647 Gao the Grid dp,思路,格中取同一行的三点,经典 难度:3
- ZOJ 3647 Gao the Grid (计数 + pick定理)
- Gao the Grid ZOJ 3647 数三角形
- ZOJ 3647 Gao the Grid
- ZOJ 3647 Gao the Grid
- ZOJ-3647 Gao the Grid
- zoj 3647 Gao the Grid
- zoj 3535 Gao the String II(ac自动机+dp)
- ZOJ 3535 Gao the String II
- zoj 3535 Gao the String II(AC自动机+DP)
- ZOJ 3780 Paint the Grid Again 拓扑排序 策略题
- ZOJ 3466 The Hive II