Comet OJ - Contest #2简要题解
前言:
我没有小裙子,我太菜了。
A 因自过去而至的残响起舞
https://www.cometoj.com/contest/37/problem/A?problem_id=1528
容易发现那玩意增长的飞快,只要模拟就可以了
//❤ ayaponzu*
#include
#include
#include
#include
using namespace std;
typedef long long ll;
ll n;
ll f[100000];
int main() {
int i;
scanf("%lld",&n);
f[1]=1,f[2]=1;
ll sum=2;
if(n==1) {puts("2"); return 0;}
//if(n==2) {puts("2"); return 0;}
for(i=3;in) {
printf("%d\n",i); return 0;
}
}
}
B 她的想法、他的战斗
https://www.cometoj.com/contest/37/problem/B?problem_id=1529
根据期望的线性性,可知\(E(q)=\frac{L+R}{2}\), 那么利润就是\(\frac{p-l}{r-l}(E(q)-p)\)
不难发现这东西是个二次函数,直接求最大值就可以了。
最优的\(p\)不在\([l,r]\)区间时需要特判。
//❤ ayaponzu*
#include
#include
#include
#include
using namespace std;
typedef long long ll;
typedef double f2;
ll n;
ll f[100000];
int main() {
f2 l,r,L,R;
scanf("%lf%lf%lf%lf",&l,&r,&L,&R);
f2 q=(L+R)*0.5;
f2 x=(q+l)/2;
if(xr) {
ans=q-r;
}
else ans=(-x*x+(q+l)*x-l*q)/(r-l);
if(ans>=1,x=x*x%mod) if(y&1) re=re*x%mod; return re;
}
ll C(int x,int y) {
return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main() {
int i;
ll x,y;
scanf("%d%lld%lld",&n,&x,&y);
P=x*qp(y)%mod;
for(fac[0]=i=1;i=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
ll ans=0;
for(i=0;i |