HDU6063 [2017多校联合3] RXD and math 打表 快速幂
来源:互联网 发布:淘宝商品已过期 编辑:程序博客网 时间:2024/05/21 22:28
RXD and math http://acm.hdu.edu.cn/showproblem.php?pid=6063
一言不合就打表
# include <bits/stdc++.h>using namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;const int Q = 1e9+7;LL m[100000+10];LL quick_power (LL x, LL y){ LL ret = 1; while (y > 0){ x %= Q; if (y & 1) ret = ret * x % Q; y >>= 1; x = x * x % Q; } return ret;}void mu(LL x)//莫比乌斯函数实现{ m[1]=1; for(LL i=1; i<=x; i++) for(LL j=2*i; j<=x; j+=i) { m[j]-=m[i]; }}int main (){ memset (m, 0, sizeof (m)); mu (100000); /*for (int i=0; i<100; ++i){ cout << mu[i] << " " <<endl; }*/ cout << "n" << "______" << "k" << "_______" << "ans" << endl; for (int n=1; n<=5; ++n){ for (int k=1; k<=5; ++k){ LL ans = 0; LL x = quick_power (n, k); for (int r=1; r<=x; ++r){ ans += m[r] * m[r] * floor(sqrt(x * 1.0 / r)); } cout << n << "______" << k << "_______" << ans << endl; } } return 0;}
发现运行的结果是n的k次幂,于是上模板
# include <bits/stdc++.h>//万能头文件,编译时间长using namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;const int Q = 1e9+7;LL quick_power (LL x, LL y)//快速幂{ LL ret = 1; while (y > 0) { x %= Q; if (y & 1) ret = ret * x % Q; y >>= 1; x = x * x % Q; } return ret;}int main (){ LL n, k, Case = 1; while (scanf ("%lld%lld", &n, &k) != EOF) { LL ans = quick_power (n, k); printf ("Case #%lld: %lld\n", Case++, ans); } return 0;}
阅读全文
1 0
- HDU6063 [2017多校联合3] RXD and math 打表 快速幂
- 2017多校联合三/hdu6063 ( RXD and math )快速幂+思维
- HDU6063 RXD and math 快速幂
- HDU6063---RXD and math(2017多校联赛题目(???))
- hdu6063 RXD and math(数学/打表)
- HDU6063-RXD and math
- hdu6063-RXD and math
- HDU6063-RXD and math
- [hdu6063]RXD and math
- hdu6063 RXD and math
- 2017杭电多校联赛第三场-RXD and math (hdu6063) 找规律快速幂
- 2017多校训练Contest3: 1008 RXD and math hdu6063
- Hdu6063 RXD and math(2017多校第3场)
- HDU6063 2017杭电多校联赛第三场-RXD and math
- HDU 6063 RXD and math (打表)
- HDU 2017 多校联赛3 1008 RXD and math
- HDU 6063 RXD and math(快速幂)
- HDU 6063 RXD and math+(快速幂)+多校联赛第三场
- 推荐给大家一个优惠卷搜索网站
- java分布式服务框架Dubbo的介绍与使用
- amazeui表单提交实例
- hadoop ha配置后一个namenode不能自动failover,相当于没有配置ha
- 设计模式之禅笔记-适配器模式
- HDU6063 [2017多校联合3] RXD and math 打表 快速幂
- Handler机制更新UI线程控件
- Java二维数组
- 网络协议
- 对SAS知识的点滴回顾
- 驱动中IRP分类
- static关键字详解
- 设计模式(18)--备忘录模式
- 针对 SolidWorks Electrical 无法连接数据库解决办法