| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38946 | LYLAKIOI | 【BJ】T1 | C++ | 通过 | 100 | 856 MS | 660 KB | 1663 | 2025-11-19 20:18:12 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back #define ppc __builtin_popcount using namespace std; typedef long long ll; typedef long double db; const int maxn=1e5+10; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } namespace A{ int n,p,iv[maxn]; inline int add(int a,int b){if((a+=b)>=p)a-=p;return a;} inline int inv(int x){return x<=1e5?iv[x]:(p-inv(p%x))*1llu*(p/x)%p;} int res; void dfs(int i,int c,int s,int mask=0){ if(i<n-1)dfs(i+1,c^1,s,mask|(1<<i)); else {if(!mask)return;int nw=inv((p+1-s)%p);if(c)nw=(p-nw)%p;res=add(res,nw);return;} dfs(i+1,c,s*1llu*(1+iv[n-1-i])%p,mask); } void slv(){ n=read();p=read(); iv[1]=1;up(i,2,1e5)iv[i]=(p-iv[p%i])*1llu*(p/i)%p; res=0; dfs(0,1,iv[n]); cout<<res; } } namespace B{ db A[maxn]; void slv(){ int n=read(); up(i,1,n-1)A[i]=1; db res=0; up(i,0,1e4){ db s=-1; up(j,1,n-1)s=s*(1-A[j]),A[j]*=j*1.0/(j+1); s+=1;res+=s; } printf("%.9Lf",res); } } void slv(){ int t=read(); if(t==1)A::slv(); else B::slv(); } int main(){ //freopen("read.in","r",stdin),freopen("read.out","w",stdout); slv(); return 0; } //694282307 //58.796013305