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的更多相关文章

  1. 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, ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. ZOJ 3703 Happy Programming Contest

    偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 ...

  7. Happy Programming Contest(ZOJ3703)(01背包+路径储存)

    Happy Programming Contest  ZOJ3703 老实说:题目意思没看懂...(希望路过的大神指点) 最后那个the total penalty time是什么意思啊!!! 还是学 ...

  8. 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 ...

  9. 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 ...

  10. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

随机推荐

  1. HTML之微信全屏播放视频

    不废话,上代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...

  2. 【NOIP2014】真题回顾

    题目链接 生活大爆炸版石头剪刀布 就是个模拟,不说了 联合权值 枚举每个点,统计它任意两个儿子的联合权值,统计的时候维护sum和max就行了 飞扬的小鸟 比较好的DP题,不难想到用dp[i][j]表示 ...

  3. pycharm2018.2.1破解、汉化

    ##我只是一个搬运工  -_-   (一)先破解,破解教程直接给个网址吧,感谢各位大神的无私奉献:https://blog.csdn.net/u014044812/article/details/78 ...

  4. python unittest套件加载用例时,出现No tests were found,Empty test suite

    错误信息: 之前运行好好的脚本,突然报No tests were found,Empty test suite,详情错误信息如下所示: Launching pytest with arguments ...

  5. Python将print输出内容保存到指定文件中

    #!/usr/bin/python # -*- coding: utf- -*- import sys import os class Logger(object): def __init__(sel ...

  6. SpringBoot MAVEN编译报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:

    参考了好几篇文章没搞定,直到查询错误关键字 An unknown compilation problem occurred 分别参考了以下博客: https://blog.csdn.net/fanre ...

  7. MD5(3)

    import java.io.UnsupportedEncodingException; import java.security.PrivateKey; import java.security.S ...

  8. Base64(2)

    import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncoding ...

  9. 转 zabbix debug and zabbix使用percona插件监控mysql

    ########## https://www.cnblogs.com/keithtt/p/8542987.html zabbix使用percona插件监控mysql   1.添加percona仓库. ...

  10. 【tensorflow基础】ubuntu-tensorflow可视化工具tensorboard-No dashboards are active for the current data set.

    前言 今天基于tensorflow训练一个检测模型,本应看到训练曲线的,却只见到一个文件events.out.tfevents.1570520647.hostname,后来发现这个文件可以查看训练曲线 ...