题目:http://acm.hdu.edu.cn/showproblem.php?pid=2576
AC代码(C++):
#include <iostream> #include <queue> #include <vector> #include <set> #include <string> #include <algorithm> #include <string.h> #include <math.h> #define INF 0x3f3f3f3f #define eps 1e-8 typedef unsigned long long ull; typedef long long ll; using namespace std; ll n; ll MOD = 20090524; int main() { int t; cin >> t; while (t--) { cin >> n; ll ans = (((n*(n + 1) % (MOD*12))*(2 * n + 1)) % (MOD*12)) / 6 + n*(n + 1) / 2; ans /= 2; ans %= MOD; cout << ans << endl; } //system("pause"); }总结: 对除法取模的时候对被除数取的模要乘以除数.