# bzoj4872 分手是祝愿

## Description

Zeit und Raum trennen dich und mich.

## Input

1 ≤ n ≤ 100000, 0 ≤ k ≤ n；

4 0
0 0 1 1

## Sample Output

512

//%std
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define lovelive long long
#define lc son[x][0]
#define rc son[x][1]
#define lowbit(x) (x&(-x))
#define pt vc
const lovelive mod=100003;
const int N=1e5+100;
{
int p=1;
x=0;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
p=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=x*10+c-48;
c=getchar();
}
x*=p;
}
lovelive pow1(lovelive x,lovelive k)
{
lovelive r=1;
if(k<0)
k+=mod-1;
while(k)
{
if(k&1)
r*=x;
x*=x;
r%=mod;
x%=mod;
k>>=1;
}
return r;
}
lovelive f[N],d[N];
int main()
{
lovelive n,k,sum=0,jc=1;
f[n]=1;
for(lovelive i=n-1;i>k;i--)
{
f[i]=((n-i)*f[i+1]+n)*pow1(i,-1)%mod;
}
for(lovelive i=1;i<=n;i++)
jc=(jc*i)%mod;
for(int i=1;i<=k;i++)
f[i]=1;
for(int i=1;i<=n;i++)
f[i]=f[i-1]+f[i]%mod;
for(int i=1;i<=n;i++)
f[i]=f[i]*jc%mod;
for(int i=1;i<=n;i++)
for(int i=n;i>=1;i--)
if(d[i])
{
++sum;
for(int j=1;j*j<=i;j++)
if(i%j==0)
{
d[j]^=1;
if(j*j!=i)
d[i/j]^=1;
}
}
cout<<f[sum]<<"\n";
return 0;
}
/*
2 0
1 1
*/
View Code

posted @ 2018-04-15 19:16  NicoDafaGood  阅读(113)  评论(0编辑  收藏  举报