摘要: 想法其实是挺巧妙的。。找到所有数的所有因数,统计最大的一个出现过K次的因数。Code:#include <cstdio>#include <iostream>using namespace std;long a[1001];long s[1000001];long gcd(long a,long b){ if (a%b==0) { return b; } if (b%a==0) { return a; } return gcd(b,a%b);}void qqsort(long l,long r){ long i=l,j=r,x; x=s[(l+r)/2]; /*cout 阅读全文
posted @ 2012-05-14 21:46 JS_Shining 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 搞了几次才过。。。太弱了。。。本题的关键想到扩展并查集,在基础并查集的基础上额外维护一个集合的大小和当前点在集合中的位置就可以了。Code:type node=record fa,d,l:longint;end;var f:array [0..30001] of node; m,a,b,i:longint; ch:char;function find(x:longint):longint; var i,j,p,q:longint; begin i:=x; while f[i].fa<>i do i:=f[i].fa; p:=i;i:=x; while ... 阅读全文
posted @ 2012-05-13 11:13 JS_Shining 阅读(1050) 评论(2) 推荐(0) 编辑
摘要: 第一篇文章就弄个水题吧。。范围太小,DP或者搜索都可以过,就是无解的判断容易弄错。Code:var f:array [0..201,0..201,0..201] of longint; a:array [0..201,0..201] of longint; n,m,k,i,j,v,bx,by,ex,ey:longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; begin readln(n,m,k); readln(bx,by,ex,ey)... 阅读全文
posted @ 2012-05-12 21:34 JS_Shining 阅读(223) 评论(0) 推荐(0) 编辑