题意。。。
策略:rt
代码:
#include <stdio.h> #include <string.h> #define temp 10003 int ans(int n, int p){ int res = 1; n %= temp; while(p){ if(p&1) res = (n*res)%temp; n = (n*n)%temp; p /= 2; } return res; } int main(){ int t, n, p; scanf("%d", &t); while(t --){ scanf("%d%d", &n, &p); int sum = 0; //这里的sum初始化必须为0 for(int i = 1; i <= n; i ++){ //i从1开始 sum = (sum+ans(i, p))%temp; } printf("%d\n", sum); } return 0; }
原文地址:http://blog.csdn.net/shengweisong/article/details/39237961