题目链接: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的更多相关文章

  1. Aeroplane chess(简单概率dp)

    Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz start ...

  2. HDU 3853LOOPS(简单概率DP)

    HDU 3853    LOOPS 题目大意是说人现在在1,1,需要走到N,N,每次有p1的可能在元位置不变,p2的可能走到右边一格,有p3的可能走到下面一格,问从起点走到终点的期望值 这是弱菜做的第 ...

  3. 简单概率dp(期望)-zoj-3640-Help Me Escape

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4808 题目大意: 有n条路,选每条路的概率相等,初始能力值为f,每 ...

  4. hdu 4576(简单概率dp | 矩阵优化)

    艰难的一道题,体现出菜菜的我... 首先,先吐槽下. 这题到底出题人是怎么想的,用普通概率dp水过??? 那为什么我概率dp写的稍微烂点就一直tle?  感觉很不公平.大家算法都一致,因为我程序没有那 ...

  5. LightOJ 1030 【概率DP求期望】

    借鉴自:https://www.cnblogs.com/keyboarder-zsq/p/6216762.html 题意:n个格子,每个格子有一个值.从1开始,每次扔6个面的骰子,扔出几点就往前几步, ...

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

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

  8. hdu 4405 Aeroplane chess(简单概率dp 求期望)

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  9. Throwing Dice(概率dp)

    C - Throwing Dice Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Lig ...

随机推荐

  1. 安装cocoaPod 的问题

    APPLEdeiMac:cocoapod案例 apple$ pod install Analyzing dependencies [!] The dependency `Reachability (~ ...

  2. [Lua]cocos framework

    package_support function cc.register(name, package) function cc.load(...) function cc.bind(target, . ...

  3. Java学习----finally块

    public class Test { String x; public static void main(String[] args) { Test test = new Test(); try { ...

  4. 滑动开关效果 css3滑动开关】纯CSS3代码实现滑动开关效果-css3滑动效果-css3左右滑动

    今天看到一篇有关 css3事件的博文,一时兴起便整理下相关的资料. 点击按钮,可以实现开关的滑动效果. 今天看到一篇有关 css3事件的博文,一时兴起便整理下相关的资料. 点击按钮,可以实现开关的滑动 ...

  5. jquery live()只支持css选择器

    昨天在处理过keypress键盘事件后,今天要把用户在页面上动态添加的字段条目加上删除功能,就是在每个字段后面加上一个漂亮的小按钮,当用户点击这个按钮,相应的条目就被从数据库中删除. 为了实现这种功能 ...

  6. StringBuilder字符串拼接类

    StringBuilder StringBuilder是在using System.Text命名空间下的一个成员. 在做字符串拼接的时候,因为字符串是引用类型,新的字符串是会再内存中创建的,所以用+号 ...

  7. 关于webapp的一个webframe问题

    最近重启ios webapp的项目,将之前的框架拿过来发现出现了错误,错误出现在写JSAlart控件的WebFrame上,xcode会报WebFrame是未定义的错误.由于之前使用的是ios5的 sd ...

  8. Ajax请求ashx一般处理程序实现文件下载

    具体功能为,在文件数据列表中选择一行,点击表格上方的下载按钮,下载文件.由于表格中不包含文件路径,只能取到在数据库表中的ID,所以具体实现就是这样:首先点击一行,获取点击的一行数据的ID,用Ajax传 ...

  9. How To mount/Browse Windows Shares【在linux{centos}上挂载、浏览window共享】

    How to mount remote Windows shares Contents Required packages Basic method Better Method Even-better ...

  10. winfrom获得鼠标的坐标

    Point mouse = this.PointToScreen(Control.MousePosition);label1.Text = mouse.X.ToString() + ":&q ...