Self powers

Problem 48

The series, 11 + 22 + 33 + ... + 1010 = 10405071317.

Find the last ten digits of the series, 11 + 22 + 33 + ... + 10001000.

C++:

#include <iostream>using namespace std;typedef unsigned long long ULL;const ULL DIGITS10 = 10000000000;// 模幂函数
ULL powermod(__uint128_t a, int n, ULL m)
{__uint128_t res = 1L;while(n) {if(n & 1L) {res *= a;res %= m;}a *= a;a %= m;n >>= 1;}return (ULL)res;
}int main()
{long n;ULL ans;while(cin >> n) {ans = 0;for(int i=1; i<=n; i++) {ans += powermod(i, i, DIGITS10);ans %= DIGITS10;}cout << ans << endl;}return 0;
}

Python:

print(sum([(x**x)%(10**10) for x in range(1,1001)])%(10**10))

Project Euler Problem 48: Self powers相关推荐

  1. Project Euler Problem 104 Pandigital Fibonacci ends

    Pandigital Fibonacci ends Problem 104 The Fibonacci sequence is defined by the recurrence relation: ...

  2. Project Euler Problem 66

    Problem 66 Consider quadratic Diophantine equations of the form: x2 – Dy2 = 1 For example, when D=13 ...

  3. Project Euler Problem 27小结

    Project Euler上有很多有意思的问题,刚做到第27题,对这个问题做个小结. Problem 27: Euler有一个著名的方程n^2+n+41,当n=0到39时,方程结果均为质数.如今人们用 ...

  4. Project Euler Problem 27 Quadratic primes

    Quadratic primes Problem 27 Euler discovered the remarkable quadratic formula: n2+n+41 It turns out ...

  5. Project Euler Problem 92 Square digit chains

    Square digit chains Problem 92 A number chain is created by continuously adding the square of the di ...

  6. Project Euler Problem 25 1000-digit Fibonacci number

    1000-digit Fibonacci number Problem 25 The Fibonacci sequence is defined by the recurrence relation: ...

  7. Project Euler Problem 14 Longest Collatz sequence

    Longest Collatz sequence Problem 14 The following iterative sequence is defined for the set of posit ...

  8. Project Euler Problem 53: Combinatoric selections【组合数】

    PE其他解题报告请参考这里,本题答案在留言首条 Combinatoric selections Problem 53 There are exactly ten ways of selecting t ...

  9. Project Euler Problem 9-Special Pythagorean triplet

    我是俩循环暴力 看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记.里面有两个学习链接和例题. import mathdef calc():for i in range( ...

最新文章

  1. linux-进程的替换exec函数族
  2. 产生随机数的几种方法
  3. linux设备驱动之pci设备的驱动架构
  4. 代码规范之华为公司代码规范
  5. stk软件支持Linux,STK组件基础篇:开发入门
  6. Midway Serverless 2.0,一体化让前端研发再次提效
  7. 如何在iPhone和iPad上允许“不受信任的快捷方式”
  8. spring项目链接RabbitMQ集群
  9. 报错,sql语句中尽量不要使用*,只查询需要的字段出来
  10. Spring Cloud Sleuth + Zipkin + RabbitMQ 监控微服务应用(二)
  11. conda pip 安装NumPy速度不佳解决方案
  12. matlab list函数参数,Matlab 函数参数汇总
  13. IBM ServerGuide引导盘全系列下载网址
  14. ad18常用快捷键可以修改吗_AD18快捷键
  15. [Java] [SurfaceView] 使用EGL
  16. Android客户端与PC服务器实现Socket通信
  17. 【stm32f4 C++与C混合开发】建立keil5的ARM Compiler 6(AC6)标准库开发工程
  18. 应该来说没有什么太大的关系。因为计算精度既取决于你的级数的项
  19. Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as
  20. Array,String 方法

热门文章

  1. .net core WebAPI 初探及连接MySQL
  2. Windows10电脑线 下hosts文件地址
  3. java微信上传本地视频教程_java微信开发之上传下载多媒体文件,java上传下载_PHP教程...
  4. 为什么选择spark
  5. Pandas——Series与DataFrame
  6. 卷积,DFT,FFT,图像FFT,FIR 和 IIR 的物理意义。
  7. linux6.8设置中文界面,Linux下安装多媒体中心 Kodi 18.8 新版本并设置中文界面
  8. 基于B+树的学生信息管理系统
  9. SPOJ DQUERY D-query(主席树 区间不同数个数)
  10. 洛谷——P1176 路径计数2