
杂
文章平均质量分 57
lj_acm
这个作者很懒,什么都没留下…
展开
-
hdu 4311
直接暴力的话,O(n2),肯定会超时。分解到两个轴上,通过递推求解,O(nlgn)。要理解这种高效求距离的方法。数轴上的某一点到其他点的距离,可通过从小到大或从大到小递推来做。 #include #include #include #define ll _int64 using namespace std; const int maxn=100010; int x[maxn],y[ma原创 2012-12-27 16:05:35 · 563 阅读 · 0 评论 -
poj 2247
枚举,貌似数据量挺大的,其实不大,就看最深层的tot加了多少次,就可估计出真正的规模 //枚举 #include #include #include #define ll long long using namespace std; const int maxn=2000000000; int num[10000]; int main() { ll i1,i2,i3,i4;//注意原创 2012-12-31 11:47:44 · 517 阅读 · 0 评论 -
hdu 2045
这题不难,没有涉及算法。主要是熟练了一下指针。主要思想就是,设定一个规范模式,然后朝着这个规范模式化解,代码可以优化,有许多冗余 的地方。 #include #include #include using namespace std; const int maxn=1000000; char sa[maxn],sb[maxn]; int main() { while(scanf("%s原创 2013-01-03 17:12:25 · 452 阅读 · 0 评论 -
hdu 1396
递推,找规律 #include #include 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=原创 2013-02-25 19:27:00 · 618 阅读 · 0 评论 -
poj 3210
这道题虽然是道YY题,就两行代码,但挺锻炼思维的 #include #include 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; }原创 2013-03-24 14:03:11 · 723 阅读 · 0 评论 -
poj 1035
暴力水过,79ms #include #include #include 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])) { i原创 2013-04-18 22:07:47 · 872 阅读 · 0 评论 -
poj 1815
模拟,标记六个方向的位置为0,1,2。。。,然后记录当前位置六种走法所要朝向的方向,而我们所需要的就是每个位置的这几个方向,很显然,其中的front所得到的方向就是当前所朝向的方向。 #include #include #include using namespace std; struct node { int front,back,left,right,up,d原创 2013-08-06 17:34:20 · 796 阅读 · 0 评论