猜公式:

  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. Question about pairing/bonding?

    Except that on android you can bypass the pairing dialog if you know the PIN in advance through a di ...

  2. sharepoint 2010 切换域

    前提: 现在已经有一个sharepoint 2010的环境,当前域为contosoA.com,有个需求需要将这个域切换到域contosoB.com.下面是成功操作的步骤. 1.数据最重要 备份所有数据 ...

  3. 000 VS2013 c++ 框架

    #include <Windows.h> //全局函数声明 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, ...

  4. PB中获取datawindow提交的sql语句

    PB的群里边,有人问的到这个问题,查了一下,综合了两条回答,得到了答案 1.DW 控件的SQLpreview 事件里的sqlsyntax 参数即是 2.pb一般使用占位符优化SQL语句,也就是你看到的 ...

  5. OA Framework - How to Find the Correct Version of JDeveloper to Use with E-Business Suite 11i or Release 12.x (Doc ID 416708.1)

    APPLIES TO: Oracle Applications Framework - Version 11.5.10.0 to 12.2.2 [Release 11.5.10 to 12.2] In ...

  6. Team Homework #3 软件工程在北航——IloveSE

    任务要求: 采访以前上过北航  (计算机系/软件学院) 软件工程课的同学.现在上研/工作的也可以. 采访问题如下:* 平均每周花在这门课上的时间 (包括上课/作业/上机)    * 平均写的代码总行数 ...

  7. 团队项目的NABC(截图软件)

    我们小组要开发的软件是基于windows上的截图软件,其NABC如下. 1.need: 首先,截图工具是几乎每个用户都会用到的,不管是在工作中,还是在学习上,其针对的人群从学生到上班族不等, 所以,他 ...

  8. Android开发随笔4

    昨天: 今天: 编写代码

  9. xml基础学习笔记04

    今天继续xml学习,主要是:SimpleXML快速解析文档.xml与数组相互转换 .博客中只是简单的做一个学习记录.积累.更加详细的使用方法,可以查看php手册 1.SimpleXML快速解析文档 前 ...

  10. public、protect、private在父类子类中使用

    先贴出一张,直观的.估计大家都见过的关于public.protect.private的范围图 作用域 当前类 同一package 子孙类 其他package public     T         ...