T1 hit balloon: expected recursion, not concerned about the specific location, so\ (f[i][j]\)Said there was\ (i\),\ (j\)Line, the column is not finished;\ (code\):
#include <cstdio> #include <algorithm> #include <ctype.h> #include <vector> #include <queue > #include <cstring> #define LOWBIT (x) (x&-x) #define LL Long long #define LD double #include <map> #incl ude<stdlib.h> #include <ctime> #define MOD 19260817 using namespace std; Char buf[1<<20],*p1,*p2; Inline Char GC () {//return GetChar (); Return p1==p2&& (p2= (p1=buf) +fread (Buf,1,1<<20,stdin)) ==p1?0:*p1++; } template<typename t> inline void read (T &x) {char tt; BOOL flag=0; while (!isdigit (TT=GC ()) &&tt!= '-'); tt== '-'? (flag=1,x=0):(x=tt-' 0 '); while (IsDigit (TT=GC ())) x=x*10+tt-' 0 '; if (flag) x=-x; } int n,m;int hang,lie;ld f[2005][2005];bool heng[2005],zong[2005];ld dfs (int x,int y) {if (f[x][y]!=-1) return f[x][y]; if (!x&&!y) return f[x][y]=0.0;f[x][y]=0.0; f[x][y]+= (x)? (Dfs (X-1,y) *1.0*x* (n-y)): 0.0;//printf ("%.2lf\n", F[x][y]); f[x][y]+= (y)? (Dfs (X,Y-1) *1.0*y*(n-x)): 0. 0; f[x][y]+= (x&&y)? (Dfs (X-1,Y-1) *1.0*x*y): 0.0; Return f[x][y]= (f[x][y]+n*n*1.0)/((x+y) *n-x*y);} int main () {read (n), read (m); for (int i=1;i<=m;i++) {int x, y; Read (x), read (y); Heng[x]=zong[y]=1; } for (int i=1;i<=n;i++) hang+=!heng[i],lie+=!zong[i]; for (int i=0;i<=n;i++) for (int j=0;j<=n;j++) f[i][j]=-1; printf ("%.2lf", DFS (Hang,lie)); return 0;}
T2 Interesting series: Cattleya number + factorization of mass factor\ (code:\)
#include <cstdio> #include <algorithm> #include <ctype.h> #include <vector> #include <queue > #include <cstring> #define LOWBIT (x) (x&-x) #define LL Long long #define LD double #include <map> #incl Ude<stdlib.h> #include <ctime> using namespace std; Char buf[1<<20],*p1,*p2; Inline Char GC () {//return GetChar (); Return p1==p2&& (p2= (p1=buf) +fread (Buf,1,1<<20,stdin)) ==p1?0:*p1++; } template<typename t> inline void read (T &x) {char tt; BOOL flag=0; while (!isdigit (TT=GC ()) &&tt!= '-'); tt== '-'? (flag=1,x=0):(x=tt-' 0 '); while (IsDigit (TT=GC ())) x=x*10+tt-' 0 '; if (flag) x=-x; } const int MAXN=1000002;LL pri[maxn<<1],phi[maxn<<1],s[maxn<<1],ans=1;ll N,mod,tot;bool BOOK[MAXN <<1];void Modify (int x,int d) {while (1) {if (pri[phi[x]]==0) break; S[phi[x]]+=d; X/=PRI[PHI[X]]; }}void sent () {for (int i=2;i<=n<<1;i++) {if(!book[i]) Pri[++tot]=i,phi[i]=tot; for (int j=1;pri[j]*i<= (n<<1) &&j<=tot;j++) {book[pri[j]*i]=1,phi[pri[j]*i]=j; if (i%pri[j]==0) break; }}}int Main () {//1 1 5//Freopen ("Interesting.in", "R", stdin);//Freopen ("Interesting.out", "w", stdout); Read (n), read (mod); sent (); for (int i=n<<1;i>n;i--) modify (i,1); for (int i=1;i<=n;i++) modify (i,-1); Modify (n+1,-1); for (int. i=1;i<=tot;i++) while (s[i]--) ans= (ans*pri[i])%mod; printf ("%lld", ans); return 0;}
T3 Distance: Pending repair\ (code:\)
待补
2018.10.18 Practice Math Training