随笔分类 - 

摘要:模拟,标记六个方向的位置为0,1,2。。。,然后记录当前位置六种走法所要朝向的方向,而我们所需要的就是每个位置的这几个方向,很显然,其中的front所得到的方向就是当前所朝向的方向。#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct node{ int front,back,left,right,up,down;};node b_ch(node op){ node tem; tem.front=op.back; tem.back=op.front; 阅读全文
posted @ 2013-05-20 01:15 LJ_COME!!!!! 阅读(148) 评论(0) 推荐(0)
摘要:暴力水过,79ms#include <iostream> #include <cstdio> #include <cstring> using namespace std; char tx[10000+10][20]; char s[20]; int len[10000+10],loc[10000+10]; int main() { int i=0; while(scanf("%s",tx[i])) { if(strcmp(tx[i],"#")==0) break; len[i]=strlen(tx[i]); i++; 阅读全文
posted @ 2013-04-18 22:07 LJ_COME!!!!! 阅读(115) 评论(0) 推荐(0)
摘要:这道题虽然是道YY题,就两行代码,但挺锻炼思维的#include <iostream> #include <cstdio> using namespace std; int main() { int n; while(cin>>n&&n) { if(n%2==0) cout<<"No Solution!"<<endl; else cout<<n-1<<endl; } return 0; } 阅读全文
posted @ 2013-03-24 14:03 LJ_COME!!!!! 阅读(114) 评论(0) 推荐(0)
摘要:递推,找规律#include <iostream> #include <cstdio> using namespace std; int count[510]; int main() { count[1]=1; int i,j; for(i=2;i<=500;i++) { int t=count[i-1]; for(j=1;j<=i;j++) t=t+i+1-j; for(j=1;i-j>=j;j++) t=t+i-j+1-j; count[i]=t; } int n; while(cin>>n) cout<<count[n]& 阅读全文
posted @ 2013-02-25 19:27 LJ_COME!!!!! 阅读(130) 评论(0) 推荐(0)
摘要:这题不难,没有涉及算法。主要是熟练了一下指针。主要思想就是,设定一个规范模式,然后朝着这个规范模式化解,代码可以优化,有许多冗余 的地方。#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=1000000; char sa[maxn],sb[maxn]; int main() { while(scanf("%s %s",sa,sb)!=EOF) { getchar(); int len1=strlen(sa 阅读全文
posted @ 2013-01-03 17:12 LJ_COME!!!!! 阅读(128) 评论(0) 推荐(0)
摘要:枚举,貌似数据量挺大的,其实不大,就看最深层的tot加了多少次,就可估计出真正的规模//枚举 #include <iostream> #include <stdio.h> #include <algorithm> #define ll long long using namespace std; const int maxn=2000000000; int num[10000]; int main() { ll i1,i2,i3,i4;//注意long long 因为虽然按理说是不会爆int,相乘这个过程可能会溢出 int tot=0; for(i1=1;i 阅读全文
posted @ 2012-12-31 11:47 LJ_COME!!!!! 阅读(136) 评论(0) 推荐(0)
摘要:直接暴力的话,O(n2),肯定会超时。分解到两个轴上,通过递推求解,O(nlgn)。要理解这种高效求距离的方法。数轴上的某一点到其他点的距离,可通过从小到大或从大到小递推来做。#include <iostream> #include <cstdio> #include <algorithm> #define ll _int64 using namespace std; const int maxn=100010; int x[maxn],y[maxn],rx[maxn],ry[maxn]; ll disx[maxn],disy[maxn]; int n; l 阅读全文
posted @ 2012-12-27 16:05 LJ_COME!!!!! 阅读(128) 评论(0) 推荐(0)