【BestCoder Round #22】题解、
来源:互联网 发布:windows fips 编辑:程序博客网 时间:2024/06/04 20:25
A:没看懂题,
我猜是转化二进制,然后去掉前导和后面的0,然后反过来,再转10进制输出。
B:没看懂题,出题人卡语文都是某种生物……QAQ
C:物理题:
可以三分模拟退火神马的
但是有O(1)公式。
推导过程在代码中:
/*
输入H,V
设Vx,Vy,t,S
Vx^2+Vy^2=V^2
4.9t*t-Vx*t=H
S=Vy*t
求maxS
*/
/*输入H,V设Vx,Vy,t,SVx^2+Vy^2=V^24.9t*t-Vx*t=HS=Vy*t求maxS*/#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int g;double V,H;int main(){//freopen("C.in","r",stdin);scanf("%d",&g);while(g--){scanf("%lf%lf",&H,&V);printf("%.2lf\n",sqrt(((V*V+9.800*H)*(V*V+9.800*H)-96.04*H*H)/96.04000));}return 0;}
D:傻逼莫队。
式子:len!/(now[1]!*now[2]!*……*now[30000]!)
转移:
for(int i=1;i<=q;i++){while(r<query[i].r){ans*=(++len);ans%=mod;ans*=niyuan[(++now[src[++r]])];ans%=mod;}while(r>query[i].r){ans*=niyuan[(len--)];ans%=mod;ans*=(now[src[r--]]--);ans%=mod;}while(l<query[i].l){ans*=niyuan[(len--)];ans%=mod;ans*=(now[src[l++]]--);ans%=mod;}while(l>query[i].l){ans*=(++len);ans%=mod;ans*=niyuan[(++now[src[--l]])];ans%=mod;}ret[query[i].note]=ans;}
代码:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 30500#define mod 1000000007#define LL long long using namespace std;LL Ksm(int x,int y){LL t=x,res=1;for(;y;y>>=1,t=(LL)t*t%mod)if(y&1)res=(LL)res*t%mod;return res;}LL Inv(int x){if(!x)x=mod;return Ksm(x,mod-2);}LL niyuan[N];void init(){for(int i=0;i<=30000;i++){niyuan[i]=Inv(i);}}struct Q{ int l,r,id,note; long long ret;}query[N];int n,m,q,g,block;int src[N],cnt[N];long long ans;int l,r,len;int now[N],ret[N];int cmplr(Q a,Q b){if(a.l==b.l)return a.r<b.r;return a.l<b.l;}int cmpid(Q a,Q b){if(a.id==b.id)return a.r<b.r;return a.id<b.id;}int cmpno(Q a,Q b){return a.note<b.note;}void build(){ int i,j,k; scanf("%d%d",&n,&q); for(i=1;i<=n;i++)scanf("%d",&src[i]); block=(int)sqrt(n); m=(n-1)/block+1; for(i=1;i<=q;i++)scanf("%d%d",&query[i].l,&query[i].r),query[i].note=i; sort(query+1,query+q+1,cmplr); int id=1; for(i=1;i<=q;i++) { while(id*block<=query[i].l)id++; query[i].id=id; } sort(query+1,query+q+1,cmpid);}void modui(){r=0,l=1;ans=1ll,len=0;memset(now,0,sizeof(now));<span style="white-space:pre"></span>for(int i=1;i<=q;i++)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>while(r<query[i].r)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>ans*=(++len);<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>ans*=niyuan[(++now[src[++r]])];<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>while(r>query[i].r)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>ans*=niyuan[(len--)];<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>ans*=(now[src[r--]]--);<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>while(l<query[i].l)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>ans*=niyuan[(len--)];<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>ans*=(now[src[l++]]--);<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>while(l>query[i].l)<span style="white-space:pre"></span>{<span style="white-space:pre"></span>ans*=(++len);<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>ans*=niyuan[(++now[src[--l]])];<span style="white-space:pre"></span>ans%=mod;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>ret[query[i].note]=ans;<span style="white-space:pre"></span>}int main(){//freopen("test.in","r",stdin);int i;scanf("%d",&g);init();while(g--){build();modui();for(i=1;i<=q;i++)printf("%d\n",ret[i]);}return 0;}
附一个样例:
input:
1
5 2
1 2 1 2 1
1 2
4 5
output:
2
2
那个,还没测完我就勇敢地发了题解。
有bug请请喷谢谢,但是思想都是对的。
复制去Google翻译翻译结果
而(R<查询[I].R)
{接送时段
年*=(LEN++);
%=MOD一年;
niyuan年*=[(++现在[来源[++R]]);
%=MOD一年;
}接送时段
而(R>查询[I].R)
{接送时段
niyuan年* =[(len--)];
%=MOD一年;
*=年(现[来源[ - R]] -);
%=MOD一年;
}接送时段
而(L<查询[I].L)
{接送时段
niyuan年* =[(len--)];
%=MOD一年;
*=年(现[来源[我++]] - );
%=MOD一年;
}接送时段
而(L>查询[I].L)
{接送时段
年*=(LEN++);
%=MOD一年;
niyuan年*=[(++现在[来源[ - L]);
%=MOD一年;
}接送时段
{接送时段
年*=(LEN++);
%=MOD一年;
niyuan年*=[(++现在[来源[++R]]);
%=MOD一年;
}接送时段
而(R>查询[I].R)
{接送时段
niyuan年* =[(len--)];
%=MOD一年;
*=年(现[来源[ - R]] -);
%=MOD一年;
}接送时段
而(L<查询[I].L)
{接送时段
niyuan年* =[(len--)];
%=MOD一年;
*=年(现[来源[我++]] - );
%=MOD一年;
}接送时段
而(L>查询[I].L)
{接送时段
年*=(LEN++);
%=MOD一年;
niyuan年*=[(++现在[来源[ - L]);
%=MOD一年;
}接送时段
0 0
- 【BestCoder Round #22】题解、
- BestCoder Round #22 【题解】
- BestCoder Round #4 题解
- BestCoder Round #18题解
- BestCoder Round #84 题解
- BestCoder Round #85题解
- BestCoder Round #85题解
- BestCoder Round #84题解报告
- BestCoder Round #85题解报告
- BestCoder Round #85 题解(待续)
- BestCoder Round #85 前三题题解
- BestCoder Round #85题解报告
- BestCoder Round #86题解报告
- BestCoder Round #86题解报告
- BestCoder Round #89题解报告
- BestCoder Round #92 题解 (待续)
- BestCoder Round #11 (Div. 2)题解集合
- BestCoder Round #11 (Div. 2) 前三题题解
- SQLCipher错误之java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared from loader dalvik.system.
- arm与dsp通信
- 地图比例尺知识
- Xcode6 ios8的定位新特性
- 大型网站架构不得不考虑的10个问题
- 【BestCoder Round #22】题解、
- TIMESAMPE_HEX_TO_CHAR函数 解决时间16进制可视化问题
- java递归查找最小数
- 抽象工厂模式
- QT开发环境大搭建
- java文件编译后包含的信息
- android 退出整个APP
- OpenGL入门学习(一)
- The connection to adb is down, and a severe error has occured.