lightoj 1027 简单概率dp
题目链接:http://lightoj.com/volume_showproblem.php?problem=1027
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; int sum,ans,n,m; int Gcd(int a,int b){
if(a%b == ) return b;
return Gcd(b,a%b);
}
int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
int T;
cin>>T;
for(int cas=;cas<=T;cas++){
scanf("%d",&n);
m = n;
sum = ;
for(int i=;i<=n;i++){
int a;
scanf("%d",&a);
if(a<) m--;
sum += abs(a);
}
printf("Case %d: ",cas); if(m == ) { printf("inf\n"); continue; }
int G = Gcd(sum,m);
printf("%d/%d\n",sum/G,m/G);
}
}
lightoj 1027 简单概率dp的更多相关文章
- Aeroplane chess(简单概率dp)
Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz start ...
- HDU 3853LOOPS(简单概率DP)
HDU 3853 LOOPS 题目大意是说人现在在1,1,需要走到N,N,每次有p1的可能在元位置不变,p2的可能走到右边一格,有p3的可能走到下面一格,问从起点走到终点的期望值 这是弱菜做的第 ...
- 简单概率dp(期望)-zoj-3640-Help Me Escape
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4808 题目大意: 有n条路,选每条路的概率相等,初始能力值为f,每 ...
- hdu 4576(简单概率dp | 矩阵优化)
艰难的一道题,体现出菜菜的我... 首先,先吐槽下. 这题到底出题人是怎么想的,用普通概率dp水过??? 那为什么我概率dp写的稍微烂点就一直tle? 感觉很不公平.大家算法都一致,因为我程序没有那 ...
- LightOJ 1030 【概率DP求期望】
借鉴自:https://www.cnblogs.com/keyboarder-zsq/p/6216762.html 题意:n个格子,每个格子有一个值.从1开始,每次扔6个面的骰子,扔出几点就往前几步, ...
- sgu 495. Kids and Prizes (简单概率dp 正推求期望)
题目链接 495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: s ...
- Discovering Gold LightOJ - 1030 (概率dp)
You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave c ...
- hdu 4405 Aeroplane chess(简单概率dp 求期望)
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- Throwing Dice(概率dp)
C - Throwing Dice Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Lig ...
随机推荐
- 如何改app图标名称
InfoPlist.strings文件里写上: CFBundleDisplayName="中文名字";
- IOS LocationManager定位国内偏移,火星坐标(GCJ-02)解决方法
转载自:http://blog.csdn.net/swingpyzf/article/details/16972351 纠偏也可参考:http://www.2cto.com/kf/201310/253 ...
- [lua]协同式多任务,统筹运用
-- CPM:关键路径法(Critical Path Method) jobBase = { schedule = function ( self, job, task, ... ) --由具体job ...
- v880 debug
zte v880手机,ubuntu中配置真机调试, 1.开启手机调试模式2.增加/etc/udev/rules.d/51-android.rules. 内容如下:SUBSYSTEM=="us ...
- 无线端web开发学习总结
无线web开发之前要做一些准备工作:一.必需的reset样式库1.其中的重点是盒模型box-sizing:由原来pc端的content-box改为border-box. *, *:before, *: ...
- CANoe 入门 Step by step系列(二)CAPL编程【转】
CAPL就是Communication Application Programming Laguage的缩写,CAPL类似于C语言的语法,因此所有的语法请参考C语言教程,这里不在这里进行详述,关于C语 ...
- js插件动态加载js、css解决方案
最近因为工作需要做了一个js自动导入的插件,一开始很天真的以为动态创建个script添加到head中就ok了,试了之后才发现了问题,就是如果同时引入了多个js文件,而且后一个文件中用到了前一个文件中的 ...
- js中对象调用对象中的方法
var o = {a:"abc", b:{ c:function(param){ alert(this.a); //这里的this指向的不是o而是b,所以this是没有a属性的,这 ...
- iOS: 学习笔记, swift扩展
// // YYExtension.swift // // Created by yao_yu on 14-7-18. // Copyright (c) 2014年 yao_yu. All right ...
- github基础命令
github被zf断断续续的墙掉,只能多试几次;习惯用svn了,作为git新手,把svn跟git命令对比了一下,瞬间发现好方便记忆了: (1)获取代码仓库克隆:https://github.com/c ...