记录编号 147790 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 [国家集训队 2011] Crash的数字表格 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 7.640 s
提交时间 2015-02-04 00:08:25 内存使用 38.92 MiB
显示代码纯文本
/*====================Asm.Def========================*/
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <map>
using namespace std;
#ifdef DEBUG
	FILE *in = fopen("test", "r");
	#define out stdout
#else
	FILE *in = fopen("nt2011_table.in", "r");
	FILE *out = fopen("nt2011_table.out", "w");
#endif
template <typename T>inline void getd(T &x){
	char ch = fgetc(in);bool neg = 0;
	while(!isdigit(ch) && ch != '-')ch = fgetc(in);
	if(ch == '-')ch = fgetc(in), neg = 1;
	x = ch - '0';
	while(isdigit(ch = fgetc(in)))x = x * 10 + ch - '0';
	if(neg)x = -x;
}
/*======================================================*/
typedef long long LL;
const int mod = 20101009, maxn = 10000003;
int F[maxn], N, M, Min;

inline void init(){
	static bool notp[maxn];
	static int prime[2000003], cnt = 0;
	getd(N), getd(M);Min = min(N, M);
	F[1] = 1;
	int i, j, t;
	for(i = 2;i <= Min;++i){
		if(!notp[i])prime[cnt++] = i, F[i] = 1 - i;
		for(j = 0;j < cnt;++j){
			t = i * prime[j];
			if(t > Min)break;
			notp[t] = true;
			if(i % prime[j] == 0){//miu(i * prime[j]) == 0
				F[t] = F[i];
				break;
			}
			F[t] = (LL)F[i] * F[prime[j]] % mod;
		}
	}
}

int main(){
	init();
	int ans = 0, a, b, t1, t2;
	for(int i = 1;i <= Min;++i){
		a = N / i, b = M / i;
		t1 = ((LL)(a + 1) * a / 2) % mod;
		t2 = ((LL)(b + 1) * b / 2) % mod;
		ans = ((LL)t1 * t2 % mod * (LL)F[i] * i % mod + ans) % mod;
	}
	fprintf(out, "%d\n", ans >= 0 ? ans : mod + ans);
	
	#if defined DEBUG
	printf("\n%.2lfs\n", (double)clock()/CLOCKS_PER_SEC);
	#endif
	return 0;
}