hdu 4762 - Cut the Cake(大数)
来源:互联网 发布:手机网络被运营商劫持 编辑:程序博客网 时间:2024/06/05 18:40
思路十分简单,就是计算一下 n / ((m)^(n-1));
代码如下:
int cnt, ans[100];int gcd(int a, int b){ return b==0?a:gcd(b,a%b);}void cal(int x){ for(int i = 0; i < cnt; ++i) ans[i] *= x; int t = 0; for(int i = 0; i < cnt; ++i) { ans[i] += t; t = ans[i]/10000; ans[i] %=10000; } while(t) { ans[cnt++] = t%10000; t /= 10000; }}int main(){ int t, n, m, z; scanf("%d", &t); while(t--) { scanf("%d%d", &m, &n); memset(ans, 0, sizeof(ans)); z = n; cnt = 1; ans[0] = 1; for(int i = 0; i < n-1; ++i) { int g = gcd(m, z); z /= g; cal(m/g); } printf("%d/", z); for(int i = cnt-1; i >= 0; --i) i==cnt-1?printf("%d",ans[i]):printf("%.4d",ans[i]); printf("\n"); } return 0;}
- hdu 4762 - Cut the Cake(大数)
- hdu 4762 Cut the Cake (概率 + java大数)
- HDU 4762 Cut the Cake
- HDU-4762 Cut the Cake
- Cut the Cake(大数)
- hdu 4762 Cut the Cake(高精度&概率)
- hdu 4762 Cut the Cake(高精度)
- 【HDOJ 4762】 Cut the Cake (数学概率+大数)
- HDU 4328 - Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- HDU-4328-Cut the cake
- HDU 4328 Cut the cake
- hdu 4762 Cut the Cake(推导+高精度)
- HDU 4762 Cut the Cake(概率+推理+高精度)
- HDU 4762-Cut the Cake(概率+高精度)
- HDU 4762 Cut the Cake (高精度 + 公式)
- WinForm简单电子邮件发送程序
- adb连接失败 模拟器无法连接
- Hyperion essbase入门(四)计算
- Codeforces_342B_Xenia and Spies(贪心)
- (3)选择元素——(15)总结(Summary)
- hdu 4762 - Cut the Cake(大数)
- Hyperion Essbase入门(五)SmartView
- 庖丁解牛FPPopover
- c#学习中关于vs 2010遇到的中文注释,解决方案管理等器问题
- 网络协议复习
- android启动优化
- (3)选择元素——(16)延伸阅读(Further reading)
- 查找和为某一值的两个数
- 整型数组处理算法(九)给定任意一个正整数,求比这个数大且最小的“不重复数”[2014百度笔试题]