hdu 2114(立方和)
2015-11-16 19:02
316 查看
hdu 2114
证明:
(12+22+...+n2)=n(n+1)(n+2)6;(排列组合法)
(排列组合法)
证明:
(12+22+...+n2)=n(n+1)(n+2)6;(排列组合法)
(排列组合法)
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <cmath> #define LL __int64 #define MAX 0x3f3f3f3f #define MOD (10000) #define N (1000000 + 5) using namespace std; int a ; int main() { int n; while (~scanf("%d", &n)) { LL ans; n = n % MOD; if (n & 1) { ans = (n + 1) / 2 * n; } else { ans = n / 2 * (n + 1); } ans = ans * ans % MOD; if (ans < 10) { printf("000%I64d\n", ans); } else if (ans < 100) { printf("00%I64d\n", ans); } else if (ans < 1000) { printf("0%I64d\n", ans); } else { printf("%I64d\n", ans); } } }
相关文章推荐
- Palindrome Linked List
- Android 实现QQ侧滑界面之实现
- 简单计算
- 快速排序(找主元)
- lightoj1003 Drunk
- logging模块学习笔记:basicConfig配置文件
- DNS原理总结及其解析过程详解
- Find the Duplicate Number
- 大学之路
- fiddler post 二进制数据
- [POJ 2778] DNA Sequence (AC自动机+DP+矩阵加速)
- apt-get update 失败
- Qt浅谈之二十App自动重启及关闭子窗口(六种方法)
- BZOJ 2882: 工艺( 后缀自动机 )
- MyBatis入门(四)---动态SQL
- 【问题】Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds
- java项目中logger一般使用 static final
- 传纸条
- MySQLdb数据库操作
- [LeetCode] Range Sum Query - Immutable & Range Sum Query 2D - Immutable