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 ...
随机推荐
- Java环境变量批处理文件
缘由 公司需要配置大量的虚机,每个上面都要求安装 JAVA,配置环境变量,所以要求写一个批处理,一键配置环境变量 方式 网上找到了3中方式, 第一种是使用 set设置环境 变量,但是这样设置的只是临时 ...
- python基础(目录)
1.数据库操作入门 2.网络编程入门 3.编码规范 4.测试
- 设置appicon和启动图
设置appicon General – App Icon Source 设置AppIcon 图片大小 iphone 6P(@3x) 180x180 iphone 6(@2x) iphone5/5s ( ...
- Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction policies
Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction pol ...
- 为什么喜欢Kindle
为什么喜欢Kindle 有朋友问为什么那么多人喜欢用Kindle,作为刚入手一台Kindle PaperWhite 2 的人, 我想说:这个东西,应该算今年我买的最值得的设备了.它的好处太多了:1:轻 ...
- 实现基于Memcache存储的Session类
自主实现Session功能的类,基于文件方式存储Session数据,测试基本通过,还比较好玩,实际应用没有意义,只不过是学习Session是如何实现的. 使用基于文件的Session存取瓶颈可能都是在 ...
- ARM开发板系统移植-----kernel的编译
前面一篇文章http://www.cnblogs.com/linzizhang/p/4817336.html介绍了开发板上系统软件的第一部分--bootloader的编译方法. 背景:把bootloa ...
- 【原创】Android 对话框的使用
对话框即Dialog .google的官方解释:A dialog is usually a small window that appears in front of the current Acti ...
- Setup FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3
setsebool allow_ftpd_full_access onsetsebool -P ftp_home_dir on vsftpd (Very Secure File Transport P ...
- memcached 入门
memcached 是什么? Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载. memcached 能够做些什么? 适用于大型网站,处理千万及的数据,而且 ...