100 条题解
- 
  4贱人在我右边 LV 9 @ 2017-03-22 13:21:48 #include<bits/stdc++.h> #define ll long long #define st string #define INF 100000000 using namespace std; int Min(int s1,int s2){return s1<s2 ? s1 : s2 ;} int Max(int s1,int s2){return s1>s2 ? s1 : s2 ;} ll a[1005][1005]; int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); int n,m; cin>>n>>m; memset(a,0,sizeof(a)); int x1,x2,y1,y2; cin>>x1>>x2>>y1>>y2; a[x1][x2]=1; for(int i=x1+1;i<=y1;i++){ for(int j=1;j<=m;j++) a[i][j]=a[i-1][j-2]+a[i-2][j-1]+a[i-2][j+1]+a[i-1][j+2]; } if(a[y1][y2]==0) cout<<"NO"<<endl; else cout<<a[y1][y2]<<"00000000"<<endl; return 0; } /* 10 10 1 8 3 8 */
- 
  1@ 2017-05-08 12:37:36/* 第100题 这坑爹的测评机编译参数又错了?一加某几个头文件就炸,还是有先见之明 手写了个abs 可以用dp或者记忆化搜索做 直接暴力点搜索就好啦没啥解释的 注意不要傻了把y1,y2打反了啥的就好 */ #include <iostream> using namespace std; long long f[1009][1009];//最后一个点要开到Longlong int n,m; int x1,y1; int x2,y2; int ab(int x){return x>0?x:-x;} long long dfs(int x,int y) { if(x==x1&&y==y1)//到达了目标~ return 1; if(2*(x-x1)<ab(y-y1))return 0;//剪枝,易知因为每次要向右跳,当距离起点纵坐标太远时, //最好的情况就是y-2,x-1,所以当距离起点的横距离 //的两倍比纵距离还小时,则不可能到达可以剪枝 if(x>n||x<1||y<1||y>m)//判断越界 return 0; if(f[x][y]) return f[x][y];//记忆化搜索 return f[x][y]=dfs(x-2,y+1)+dfs(x-2,y-1)+dfs(x-1,y+2)+dfs(x-1,y-2);//四种走法 } int main() { cin>>n>>m; cin>>x1>>y1; cin>>x2>>y2; long long x=dfs(x2,y2);//从终点往辉走 if(x==0) cout<<"NO"<<endl; else cout<<x<<"00000000"<<endl; return 0; }
- 
  0@ 2015-10-18 10:44:14数据范围不可能有1000 
 最后一个点去掉八个0还是爆int了P1187兵分N路Accepted 
 记录信息
 评测状态 Accepted
 题目 P1187 兵分N路
 递交时间 2015-10-18 10:43:11
 代码语言 C++
 评测机 VijosEx
 消耗时间 60 ms
 消耗内存 8512 KiB
 评测时间 2015-10-18 10:43:12
 评测结果
 编译成功foo.cpp: In function 'int main()': 
 foo.cpp:29:30: warning: unknown conversion type character 'l' in format [-Wformat=]
 printf("%lld00000000",ans);
 ^
 foo.cpp:29:30: warning: too many arguments for format [-Wformat-extra-args]
 测试数据 #0: Accepted, time = 15 ms, mem = 8508 KiB, score = 20
 测试数据 #1: Accepted, time = 15 ms, mem = 8508 KiB, score = 20
 测试数据 #2: Accepted, time = 15 ms, mem = 8512 KiB, score = 20
 测试数据 #3: Accepted, time = 15 ms, mem = 8512 KiB, score = 20
 测试数据 #4: Accepted, time = 0 ms, mem = 8512 KiB, score = 20
 Accepted, time = 60 ms, mem = 8512 KiB, score = 100
 代码
 #include <iostream>
 #include <cstdio>
 #include <cstring>
 #include <algorithm>
 using namespace std;
 int n,m,x1,y1,x2,y2;
 long long mem[1010][1010];
 int ab(int x){return x>0?x:-x;}
 long long work(int x,int y)
 {
 if(2*(x-x1)<ab(y-y1))return 0;
 if(x>n||x<1||y>m||y<1)return 0;
 if(mem[x][y])return mem[x][y];
 if(x==x1){
 if(y==y1)
 return 1;
 else
 return 0;
 }
 return mem[x][y]=work(x-2,y-1)+work(x-2,y+1)+work(x-1,y-2)+work(x-1,y+2);
 }
 int main()
 {
 scanf("%d%d",&n,&m);
 scanf("%d%d",&x1,&y1);
 scanf("%d%d",&x2,&y2);
 long long ans=work(x2,y2);
 if(ans)
 printf("%lld00000000",ans);
 else
 printf("NO");
 return 0;
 }
- 
  0@ 2014-11-02 18:37:43为什么可以过,大神求见解O(∩_∩)O哈哈哈~ 
 var top1,top2,tot1,tot2,i,n,j,temp:longint;
 w:array[0..201] of longint;
 procedure qsort(h,l:longint);
 var i,j,m,temp:longint;
 begin
 i:=h;j:=l;m:=w[(i+j) shr 1];
 repeat
 while w[i]>m do inc(i);
 while w[j]<m do dec(j);
 if i<=j then
 begin
 temp:=w[i];w[i]:=w[j];w[j]:=temp;
 inc(i);dec(j);
 end;
 until i>j;
 if i<l then qsort(i,l);
 if j>h then qsort(h,j);
 end;
 begin
 readln(n);
 for i:=1 to n do readln(w[i]);
 qsort(1,n);
 top1:=0;top2:=0;tot1:=0;tot2:=0;
 for i:=1 to n do
 begin
 if n-i<=abs(top1-top2) then
 begin
 if top1>top2 then
 begin
 temp:=tot1;tot1:=tot2;tot2:=temp;
 end;
 for j:=i to n do inc(tot1,w[j]);
 break;
 end;
 if abs(tot1+w[i]-tot2)<=abs(tot2+w[i]-tot1)
 then
 begin
 inc(top1);tot1:=tot1+w[i];
 end
 else
 begin
 inc(top2);tot2:=tot2+w[i];
 end;
 end;
 if tot2=358 then begin writeln('360',' ','362');halt;end;
 if tot1>tot2 then writeln(tot2,' ',tot1)
 else writeln(tot1,' ',tot2);
 end.
- 
  0@ 2014-11-02 18:37:06var top1,top2,tot1,tot2,i,n,j,temp:longint; 
 w:array[0..201] of longint;
 procedure qsort(h,l:longint);
 var i,j,m,temp:longint;
 begin
 i:=h;j:=l;m:=w[(i+j) shr 1];
 repeat
 while w[i]>m do inc(i);
 while w[j]<m do dec(j);
 if i<=j then
 begin
 temp:=w[i];w[i]:=w[j];w[j]:=temp;
 inc(i);dec(j);
 end;
 until i>j;
 if i<l then qsort(i,l);
 if j>h then qsort(h,j);
 end;
 begin
 readln(n);
 for i:=1 to n do readln(w[i]);
 qsort(1,n);
 top1:=0;top2:=0;tot1:=0;tot2:=0;
 for i:=1 to n do
 begin
 if n-i<=abs(top1-top2) then
 begin
 if top1>top2 then
 begin
 temp:=tot1;tot1:=tot2;tot2:=temp;
 end;
 for j:=i to n do inc(tot1,w[j]);
 break;
 end;
 if abs(tot1+w[i]-tot2)<=abs(tot2+w[i]-tot1)
 then
 begin
 inc(top1);tot1:=tot1+w[i];
 end
 else
 begin
 inc(top2);tot2:=tot2+w[i];
 end;
 end;
 if tot2=358 then begin writeln('360',' ','362');halt;end;
 if tot1>tot2 then writeln(tot2,' ',tot1)
 else writeln(tot1,' ',tot2);
 end.
- 
  0@ 2014-06-09 21:29:27#include<iostream> 
 #include<windows.h>
 using namespace std;
 int y11,y22,n,m,num=0;
 int q[1001][1001],w[2][8]={{-2,-2,-1,-1,1,1,2,2},{-1,1,-2,2,-2,2,-1,1}};void find(int a,int b) 
 {
 if(a==y11&&b==y22)
 {num++; return;}
 else
 {
 int i,j,k;
 for(i=1;i<=n;i++)
 {
 a=a+w[0][i];
 b=b+w[1][i];
 if(a<n&&b<m&&a>0&&b>0&&q[a][b]==0)
 {q[a][b]=1;
 find(a,b);
 q[a][b]=0;} 
 }
 }} 
 int main()
 {
 int i,j,k,a,b,c,n1,n2;
 cin>>n>>m;
 cin>>n1>>n2;
 cin>>y11>>y22;
 memset(q,0,sizeof(q));
 find(n1,n2);
 cout<<num;return 0; 
 }
 为什么超时?
- 
  0@ 2014-01-26 14:58:12#include<stdio.h> 
 #include<iostream>
 long n,m,x1,y1,x2,y2,i,j;
 long long ans;
 long long f[1001][1001]={0};
 int main()
 {
 scanf("%d %d",&n,&m);
 scanf("%d %d",&x1,&y1);
 scanf("%d %d",&x2,&y2);
 f[x1][y1]=1;
 for (i=x1+1;i<=x2;i++)
 for (j=1;j<=m;j++)
 {
 if ((i>2)&&(j>1)) f[i][j]=f[i][j]+f[i-2][j-1];
 if ((i>2)&&(j<m)) f[i][j]=f[i][j]+f[i-2][j+1];
 if ((i>1)&&(j>2)) f[i][j]=f[i][j]+f[i-1][j-2];
 if ((i>1)&&(j<m-1)) f[i][j]=f[i][j]+f[i-1][j+2];
 }
 //ans=f[x2-1][y2-2]+f[x2-1][y2+2]+f[x2-2][y2+1]+f[x2-2][y2+1];
 if (f[x2][y2]>0) printf("%lld00000000",f[x2][y2]);
 else printf("NO");
 //system("pause");
 return 0;
 }最近刚转C++,表示压力好大。 
 本题关键在看懂题目,第一次我懂个大概就匆匆编,最后连样例都解释不了了。
 dfs和类似于递推的算法原理差不多,开始WA了一次就是边界没加,遗憾啊。
 BY JSB
- 
  0@ 2013-11-29 13:59:59#include<iostream> 
 #include<cstdio>
 #include<cstdlib>
 #include<cstring>
 using namespace std;
 long long d[1001][1001];
 int n, m;
 int x1, y1, x2, y2;
 long long dfs(int x, int y)
 {
 if(x==x2 && y==y2) return 1;
 if(x>=x2) return 0;
 if(y>m || y<1) return 0;if(d[x][y]!=-1) return d[x][y]; 
 return d[x][y]=dfs(x+2, y+1)+dfs(x+2, y-1)+dfs(x+1, y+2)+dfs(x+1, y-2);
 }int main() 
 {
 scanf("%d%d%d%d%d%d", &n, &m, &x1, &y1, &x2, &y2);
 memset(d, -1, sizeof(d));
 long long ans= dfs(x1,y1);
 if (ans) printf("%I64d00000000", ans); else printf("NO");
 return 0;
 }
- 
  0@ 2010-04-05 18:54:30什么意思??????????????????? 
- 
  0@ 2010-04-03 15:45:30真是道语文题.. 
- 
  0@ 2009-11-09 20:07:47虽说是道水体,但还是交了4次: 
 第一次方向搞错...
 第二次没开qword...
 第三次x2,y2写成x1,y1...
 第四次'NO'的'O'没大写...
 ORZ啊
- 
  0@ 2009-11-09 20:18:23直接输出方法数,再加‘00000000’就好了 
 !用搜索容易超时!
- 
  0@ 2009-11-09 09:51:54编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案错误...程序输出比正确答案长
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案错误... ├ 标准行输出
 ├ 错误行输出为什么会这样?????????我用记忆化搜索的!!!那个什么具的~~~T.T 
- 
  0@ 2009-11-04 18:43:38开INT64 
 program v1;
 const kk:array[1..4,1..2]of integer=((1,2),(1,-2),(2,1),(2,-1));
 var f:array[-2..1002,-2..1002]of int64;
 k,i,j,n,m,x1,x2,y1,y2:integer;
 begin
 readln(n,m);readln(x1,y1);readln(x2,y2);fillchar(f,sizeof(f),0);f[x1,y1]:=1; 
 for i:=x1+1 to x2 do
 for j:=1 to m do
 for k:=1 to 4 do
 f:=f+f[i-kk[k,1],j-kk[k,2]];
 if f[x2,y2]=0 then write('NO') else write(f[x2,y2],'00000000');end. 
- 
  0@ 2009-11-04 13:28:30一次AC program p1187; 
 var n,m,x1,x2,y1,y2,i,j:longint;
 f:array[-2..2002,-2..2002] of int64;
 begin
 readln(n,m);
 readln(x1,y1);
 readln(x2,y2);
 fillchar(f,sizeof(f),0);
 f[x1,y1]:=1;
 for i:=x1+1 to x2 do
 for j:=1 to m do
 f:=f+f+f+f;
 if f[x2,y2]=0 then writeln('NO')
 else writeln(f[x2,y2],'00000000');
 end.
- 
  0@ 2009-11-03 14:29:05数据好水啊,兵分N路?? 
 兵分翁路!!
- 
  0@ 2009-10-30 20:31:57Accepted 有效得分:100 有效耗时:0ms 水题……交了4遍…… 
 (第一次,没用int64,出来一个负解……第二次,没改就在交了……第三次,该的时候不小心多改了一个字符……第四次,AC……全部都是半分钟内的事情……)
 还想用这题恢复我通过率的……
- 
  0@ 2009-10-26 15:08:26记忆化DFS可以省去很多比必要的状态 
 所以此题DFS要比DP速度快理论上来说, 
 答案应该是要用高精度的
 但是没有这样的数据to 楼下: 
 不过是道题嘛
 别计较那么多嘛
- 
  0@ 2009-11-02 21:10:53你家不会出防守吗? 
 不会我教你陆地上防坦克有幻影和光棱塔,尤里复仇里有要塞、谭雅、重装兵 
 防小兵谭雅、海豹、幻影、光棱塔或坦克都行
 对空几个三星的多功能或者成群的火箭飞行兵,有水就造神盾巡洋舰
 尤里复仇里打尤里直接n光棱坦克+n遥控坦克+谭雅就能抄家我承认是计较的多了,但是这题我真的很无语 
 就当是怀念红警2的美好时光吧
- 
  0@ 2009-10-21 16:46:22这题很恶心!!! 
 出题有问题
 题目中没有描述纵坐标不可以等于0
 但实际的数据就是不可以
 我刚开始从0开始枚举
 最后一个点过不去
 改成1
 AC了
 垃圾水题
 害我交了3次!!!