static string FindReg(string src,string ptrn) {
int LP=ptrn.Length,LS=src.Length;
for(int i=0;i<LS;i++) {
int k=i;
bool ok=true;
for(int j=0;ok && j<LP;) {
int m=1;
bool plus=false;
char cur=ptrn[j++];
for(;j<LP;j++) {
if(ptrn[j]=='+') plus=true;
else if(ptrn[j]==cur) m++;
else break;
}
int s=0;
while(k+s<LS && src[k+s]==cur) s++;
if(s<m) {
ok=false; break;
} else if(plus) k+=s;
else k+=m;
}
if(ok) return src.Substring(i,k-i);
}
return null;
}
static int sstep;
static void FindAll(int N,int sum,int step,bool ord){
sstep=step;
sum/=step;
fill(new int[N],N,sum,sum-N+1,ord);
}
static void output(int[] A){
Console.Write("{0}",A[0]*sstep);
for(int i=1;i<A.Length;i++) Console.Write("/{0}",A[i]*sstep);
Console.WriteLine();
}
static void fill(int[] A,int N,int sum,int smax,bool ord) {
if(N==0 && sum==0) {
output(A);
return;
}
if(N==0 || sum<N) return;
int smin=ord ? 1 : (sum-1)/N+1;
N--;
for(A[N]=smin;A[N]<=smax;A[N]++) {
fill(A,N,sum-A[N],ord ? sum-N+1 : A[N],ord);
}
}
private static void DrawYinYang(Graphics gr,int xctr,int yctr,int rmax,int rint,int ysmall,int rsmall) {
Brush white=Brushes.White;
Brush black=Brushes.Black;
Pen BlackPen=new Pen(Color.Black,2*(rmax-rint));
gr.FillPie(black,xctr-rmax,yctr-rmax,2*rmax,2*rmax,-90,180);
gr.FillEllipse(white,xctr-rint/2,yctr-rint,rint,rint);
gr.FillEllipse(black,xctr-rint/2,yctr,rint,rint);
gr.FillEllipse(white,xctr-rsmall,yctr+ysmall-rsmall,2*rsmall,2*rsmall);
gr.FillEllipse(black,xctr-rsmall,yctr-ysmall-rsmall,2*rsmall,2*rsmall);
double rcircle=(rmax+rint)/2.0;
gr.DrawEllipse(BlackPen,(float)(xctr-rcircle),(float)(yctr-rcircle),(float)(2*rcircle),(float)(2*rcircle));
}