猜公式:

  ans=n/m^(n-1)

#include<stdio.h>
#include<string.h>
struct BigNum
{
int num[];
int len;
};
int gcd(int a,int b)
{
if(b==)
return a;
return gcd(b,a%b);
}
BigNum mul(BigNum &a,int b)
{
BigNum c;
int i,len;
len=a.len;
memset(c.num,,sizeof(c.num));
if(b==)
{
c.len=;
return c;
}
for(i=; i<len; i++)
{
c.num[i]+=(a.num[i]*b);
if(c.num[i]>=)
{
c.num[i+]=c.num[i]/;
c.num[i]%=;
}
}
while(c.num[len]>)
{
c.num[len+]=c.num[len]/;
c.num[len++]%=;
}
c.len=len;
return c;
}
int main()
{
int t,m,n,i,a,b,c;
BigNum s;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&m,&n);
s.num[]=;
s.len=;
a=n;
for(i=; i<n; i++)
{
b=m;
c=gcd(a,m);
a/=c;
b/=c;
s=mul(s,b);
}
printf("%d/",a);
for(i=s.len-; i>=; i--)
printf("%d",s.num[i]);
printf("\n");
}
return ;
}

hdu 4762 Cut the Cake (大数乘法)的更多相关文章

  1. HDU 4762 Cut the Cake (2013长春网络赛1004题,公式题)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  2. HDU 4762 Cut the Cake(公式)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  3. HDU 4762 Cut the Cake(高精度)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  4. HDU 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋 ...

  5. 2013长春网赛1004 hdu 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 & ...

  6. hdu 4762 Cut the Cake概率公式

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. ...

  7. Cut the Cake(大数相乘)

      MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly o ...

  8. HDU 4328 Cut the cake

    Cut the cake Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  9. Hdu 4762 网络赛 高精度大数模板+概率

    注意题目中的这句话he put the strawberries on the cake randomly one by one,第一次选择草莓其实有N个可能,以某一个草莓为开头,然后顺序的随机摆放, ...

随机推荐

  1. wordpress 为文章内容添加自动过滤,例如为出站链接添加nofollow,也可以将淘宝客链接转换。。

    做seo的都明白,反向链接对与网站的优化有着很重要的作用,是搜索引擎给网站排名的一个重要因素.为了添加反向链接,SEO作弊者会在论坛和博客等大量发布带无关链接的 内容.这些垃圾链接的存在给搜索引擎对网 ...

  2. .NET DES 加密

    using System; using System.Collections.Generic; using System.Text; using System.Security; using Syst ...

  3. Nginx + django windows下配置

    1.下载nginx, 去http://nginx.org/en/download.html 下载,我下载的是1.8 stable版本. 2.配置文件/conf/nginx.conf #user nob ...

  4. Android -- Layout布局文件里的android:layout_height等属性为什么会不起作用?

    有的时候,我们配置好的布局文件,在加载完成添加到我们的Activity中后发现,并没有安装我们设置的属性来布局,比如我们设置了android:layout_marginTop="100dip ...

  5. 11.6Daily Scrum

    人员 任务分配完成情况 明天任务分配 王皓南 实现网页上视频浏览的功能.研究相关的代码和功能.817 数据库测试 申开亮 实现网页上视频浏览的功能.研究相关的代码和功能.818 实现视频浏览的功能 王 ...

  6. 四则运算2--c++

    1.设计思路: 上篇已写,不在解释..... 2.源代码: #include<iostream.h>#include<stdlib.h>#include "time. ...

  7. 2015最新百度搜索引擎(seo优化)排名算法

    多少年来,对于弄清百度排名算法成为了一代又一代站长的最高目标.随着百度推出了搜索引擎网页质量**,直接揭开了神秘的百度排名算法,这是作为站长福音啊.现在小编就来为大家介绍一下. 首先想要得到直接需要的 ...

  8. Careercup - Google面试题 - 5085331422445568

    2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...

  9. 关于Viual Studio 改变编辑器背景背景及背景图片(转)

    Visual Studio背景颜色或者背景图片是可以修改的,根据个人的爱好进行相应的修改 首先先展示下效果: 修改方法如下: 1.在工具-扩展和更新-联机,此时他会自动搜索,暂时让他自己搜索去吧,这里 ...

  10. 前端之JavaScript第三天学习(8)-JavaScript-对象

    JavaScript 中的所有事物都是对象:字符串.数字.数组.日期,等等. 在 JavaScript 中,对象是拥有属性和方法的数据. 属性和方法 属性是与对象相关的值. 方法是能够在对象上执行的动 ...