M-SOLUTIONS Programming Contest
A.(n-2)*180
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; int n; int main(){
scanf("%d",&n); printf("%d\n",(n-)*);
return ;
}
B.已确定的输局<=7
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; int n,x;
char s[]; int main(){
scanf("%s",s+); n=strlen(s+);
rep(i,,n) if (s[i]=='x') x++;
if (x>) puts("NO"); else puts("YES");
return ;
}
C.现只考虑A最后胜的情况,B同理。枚举A赢第n局之前B赢了多少局i,那么若不考虑平局概率则这种情况的发生概率为A^n*B^i*C(n-1+i,i),由期望显然可以得到,一场非平局的出现概率为1-C则期望1/(1-C)会出现一场非平局,共有n+i个非平局,则期望局数为(n+i)/(1-C)。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=,mod=1e9+;
int n,A,B,C,ans,fac[N],inv[N]; int ksm(int a,int b){
int res=;
for (; b; a=1ll*a*a%mod,b>>=)
if (b & ) res=1ll*res*a%mod;
return res;
} int cc(int n,int m){ return n<m ? : 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod; } int main(){
scanf("%d%d%d%d",&n,&A,&B,&C); int ii=ksm(,mod-);
A=1ll*A*ii%mod; B=1ll*B*ii%mod; C=1ll*C*ii%mod;
int a=1ll*ksm(A+B,mod-)*A%mod,b=1ll*ksm(A+B,mod-)*B%mod;
fac[]=; rep(i,,n+n) fac[i]=1ll*fac[i-]*i%mod;
inv[n+n]=ksm(fac[n+n],mod-); for (int i=n+n; i; i--) inv[i-]=1ll*inv[i]*i%mod;
rep(i,,n-){
ans=(ans+1ll*ksm(b,i)*ksm(a,n)%mod*cc(n-+i,i)%mod*ksm(-C+mod,mod-)%mod*(n+i))%mod;
ans=(ans+1ll*ksm(a,i)*ksm(b,n)%mod*cc(n-+i,i)%mod*ksm(-C+mod,mod-)%mod*(n+i))%mod;
}
printf("%d\n",ans);
return ;
}
D.能取到最大值=总和-最大点权。于是把c从大到小排序,按DFS序分配即可。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define For(i,x) for (int i=h[x],k; i; i=nxt[i])
typedef long long ll;
using namespace std; const int N=;
int n,u,v,tot,ans,cnt,c[N],s[N],h[N],to[N<<],nxt[N<<];
struct E{ int u,v; }e[N];
void add(int u,int v){ to[++cnt]=v; nxt[cnt]=h[u]; h[u]=cnt; }
bool cmp(int a,int b){ return a>b; } void dfs(int x,int fa){
s[x]=c[++tot];
For(i,x) if ((k=to[i])!=fa) dfs(k,x);
} int main(){
scanf("%d",&n);
rep(i,,n) scanf("%d%d",&u,&v),e[i]=(E){u,v},add(u,v),add(v,u);
rep(i,,n) scanf("%d",&c[i]);
sort(c+,c+n+,cmp); dfs(,);
rep(i,,n) ans+=min(s[e[i].u],s[e[i].v]);
printf("%d\n",ans);
rep(i,,n) printf("%d ",s[i]);
return ;
}
E.答案等于(x/d)*(x/d+1)*...*(x/d+(n-1))*d^n,这就是个阶乘乘上快速幂。注意特判d=0或x/d~x/d+n-1中出现0的情况。
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std; const int mod=1e6+;
int x,d,n,T,fac[mod+]; int ksm(int a,int b){
int res=;
for (; b; a=1ll*a*a%mod,b>>=)
if (b & ) res=1ll*res*a%mod;
return res;
} int main(){
fac[]=; rep(i,,mod-) fac[i]=1ll*fac[i-]*i%mod;
for (scanf("%d",&T); T--; ){
scanf("%d%d%d",&x,&d,&n);
if (!d){ printf("%d\n",ksm(x,n)); continue; }
x=1ll*x*ksm(d,mod-)%mod;
if (!x || x+n->=mod) puts("");
else printf("%lld\n",1ll*fac[x+n-]*ksm(fac[x-],mod-)%mod*ksm(d,n)%mod);
}
return ;
}
M-SOLUTIONS Programming Contest的更多相关文章
- The Ninth Hunan Collegiate Programming Contest (2013) Problem J
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem L
Problem L Last Blood In many programming contests, special prizes are given to teams who solved a pa ...
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...
- The 15th UESTC Programming Contest Preliminary M - Minimum C0st cdoj1557
地址:http://acm.uestc.edu.cn/#/problem/show/1557 题目: Minimum C0st Time Limit: 3000/1000MS (Java/Others ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- ZOJ 3703 Happy Programming Contest
偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds Memory Limit: 65536 ...
- Happy Programming Contest(ZOJ3703)(01背包+路径储存)
Happy Programming Contest ZOJ3703 老实说:题目意思没看懂...(希望路过的大神指点) 最后那个the total penalty time是什么意思啊!!! 还是学 ...
- The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Othe ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
随机推荐
- java学习笔记(4)运算符
java中的运算符分为以下几种: 算数运算符 +.-.*./.++.--.% 关系运算符 <.<=.>.>=.==.!= 布尔运算符 &&.||.&.| ...
- Win10远程连接自己的电脑提示“登陆没有成功”的解决方案
问题:提示登录没有成功 猜想: 1)要么是账号密码输入错误,必须是系统的用户名.密码 2)要么是配置问题,配置解决如下: 1.开启允许访问远程 找到此电脑-右键属性-高级系统设置-远程-勾选允许远程连 ...
- Beta冲刺(5/5)
队名:無駄無駄 组长博客 作业博客 组员情况 张越洋 过去两天完成了哪些任务 验收了小程序的主要功能 制作Beta展示所需要用到的视频 制作Beta展示PPT 准备Beta答辩 提交记录(全组共用) ...
- 手把手带你部署K8s二进制集群
集群环境准备: [etcd集群证书生成] #mkdir -p k8s/{k8s-cert,etcd-cert}#cd k8s/etcd-cert/ #cat > ca-config.json & ...
- vim配置无插件
其实,vim插件会影响编辑器的启动速度,虽然有些插件影响不大,我依然觉得不够,其实通过简易的状态栏,可以显示必要的信息,能自定义颜色和背景甚至透明就足够了. 一.自定义状态栏其实以下内容可以写在一行上 ...
- 关于证书如何完成身份验证(SSL证书)
一.写在前面 SSL和IPsec是现在VPN技术中最为常见的,在云计算的应用环境中,SSL更受企业青睐,至于原因的话简单的说就是SSL更为简洁,不需要像IPsec那样需要额外安装客户端,这会带来软件维 ...
- 3ds Max学习日记(十二)——用Maxscript将每一帧动画导出成obj
参考链接: is there a way to through maxscript to make the time slider go to a spacific frame? 最近老师布置了要用m ...
- 快速激活Navicat Premium 12
Navicat Premium 12是一套数据库开发管理工具,支持链家MySQL.Oracle.SQL server等多种数据库,快速便捷创建.管理和维护数据库 一.下载 https://www.na ...
- 压测引起的 nginx报错 502 no live upstreams while connecting to upstream解决
对系统的某个接口进行极限压测,随着并发量上升,nginx开始出现502 no live upstreams while connecting to upstream的报错,维持最大并发量一段时间,发现 ...
- jdbc调用存储过程获取多个结果集
jdbc调用存储过程获取多个结果集 2017年07月26日 21:20:22 Kenny-Liu 阅读数:1486 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.cs ...