不想吐槽清华某人出的题了,但不看第三题那个987 行的标程,前两题还能做,此题分析在task 函数中
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#define maxn 2005
#define mod 1000000007
using namespace std ;
typedef long long lint;
int n,m,sz_p;
lint ans,ans2,t1,t2;
bool is_prime[100000005 ];
vector <int > p,e;
void prime_task(lint x)
{
memset (is_prime,1 ,sizeof (is_prime));
for (int i=2 ;i*i<=x;i++) if (is_prime[i])
for (int j=i;j*i<=x;j++) is_prime[i*j]=0 ;
for (int i=2 ;i<=x;i++) if (is_prime[i])
{
p.push_back(i);
e.push_back(0 );
}
sz_p=p.size();
}
void break_into(int x,int d)
{
if (x==1 ) return ;
for (int i=0 ;p[i]<=x&&i<sz_p;i++)
{
lint t=0 ,tt=p[i];
while (x>=tt)
{
t+=x/tt;
tt*=p[i];
}
e[i]+=d*t;
}
}
lint C(int a,int b)
{
for (int i=0 ;i<sz_p;i++) e[i]=0 ;
break_into(a,1 );
break_into(a-b,-1 );
break_into(b,-1 );
lint t=1 ;
for (int i=0 ;i<sz_p;i++)
for (int j=1 ;j<=e[i];j++) t=(t*p[i])%mod;
return t;
}
void task1()
{
ans=C(n,m);
cout <<ans<<endl;
}
void task2()
{
__________
_| _|
-> 直边 | _| <-阶梯
| _|
|_____| 这个图极为美观
t1=C(n-m-1 ,m);
t2=C(n-m-1 ,m-1 );
t2=(t2+t2)%mod;
ans2=(t1+t2)%mod;
cout <<ans2<<endl;
}
int main()
{
scanf ("%d" ,&n);
m=(n-4 )/2 ;
prime_task(2 *n);
task1();
task2();
return 0 ;
}