传送门
题解
//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
const int N=100000,mod=100003;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long LL;
typedef double db;
using namespace std;
int n,k,a[N],cnt;
LL rs,f[N],inv[N];
vector<int>vc[N];template<typename T>void read(T &x) {char ch=getchar(); x=0; T f=1;while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();if(ch=='-') f=-1,ch=getchar();for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}void solve() {For(i,1,n) For(j,1,n/i) vc[i*j].push_back(i); Rep(i,n,1) if(a[i]) {int up=vc[i].size();For(j,0,up-1) a[vc[i][j]]^=1;cnt++;}rs=cnt;if(cnt>k) {rs=k;f[n]=1; inv[1]=inv[0]=1;For(i,2,n) inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;Rep(i,n-1,k) f[i]=(((LL)n-i)*inv[i]%mod*(f[i+1]+1)%mod+1)%mod;For(i,k+1,cnt) rs=(rs+f[i])%mod;}For(i,1,n) rs=rs*i%mod;printf("%lld\n",rs);
}int main() {read(n); read(k);For(i,1,n) read(a[i]);solve();return 0;
}