HDU 1215(七夕)

データが大きすぎるので、基本的な判断残り数タイムアウトの使用は、ヒットテーブルが必要です。

#include <iostream>
using namespace std;
const int MAXN = 500005;
int arr[MAXN];

int main()
{
	for (int i = 1; i < MAXN / 2; i++)
	{
		for (int j = i * 2; j < MAXN; j += i)
			arr[j] += i;
	}

	int T;
	int n;
	cin >> T;
	while (T--)
	{
		cin >> n;
		cout << arr[n] << endl;
	}
	return 0;
}

続けてください。

公開された138元の記事 ウォンの賞賛1 ビュー6996

おすすめ

転載: blog.csdn.net/Intelligence1028/article/details/104638492