結果

問題 No.886 Direct
ユーザー ianCKianCK
提出日時 2020-01-01 04:32:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,326 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 38,528 KB
実行使用メモリ 27,092 KB
最終ジャッジ日時 2024-05-01 05:08:34
合計ジャッジ時間 3,277 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
26,832 KB
testcase_01 AC 31 ms
26,960 KB
testcase_02 AC 33 ms
26,960 KB
testcase_03 AC 33 ms
27,016 KB
testcase_04 AC 32 ms
26,956 KB
testcase_05 AC 37 ms
26,832 KB
testcase_06 AC 32 ms
26,960 KB
testcase_07 AC 33 ms
26,960 KB
testcase_08 AC 31 ms
26,964 KB
testcase_09 AC 33 ms
27,084 KB
testcase_10 AC 32 ms
27,088 KB
testcase_11 AC 32 ms
26,960 KB
testcase_12 AC 33 ms
26,960 KB
testcase_13 AC 31 ms
26,956 KB
testcase_14 AC 34 ms
27,088 KB
testcase_15 AC 34 ms
26,960 KB
testcase_16 AC 33 ms
26,960 KB
testcase_17 AC 32 ms
27,088 KB
testcase_18 AC 33 ms
26,956 KB
testcase_19 AC 33 ms
26,960 KB
testcase_20 AC 34 ms
26,964 KB
testcase_21 AC 32 ms
27,084 KB
testcase_22 AC 33 ms
26,836 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 80 ms
26,960 KB
testcase_30 AC 38 ms
26,960 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:51:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         scanf("%d%d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <vector>
using namespace std;
typedef long long int ll;

#define PB push_back
constexpr int kMod = int(1E9 + 7), kN = int(3E6 + 10);

int ABS(int n) {return n >= 0 ? n : -n;}
int gcd(int a, int b) {return  b ? gcd(b, a % b) : a;}

ll Pow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % kMod;
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}
ll Rev(ll n) {return Pow(n, kMod - 2);}

ll mu[kN];

void pre() {
	mu[0] = 0;
	mu[1] = 1;
	vector<int> prime;
	for (int i = 2; i < kN; i++) mu[i] = -3;
	for (int i = 2; i < kN; i++) {
		if (mu[i] == -3) {
			mu[i] = -1;
			prime.PB(i);
		}
		for (int j : prime) {
			if (i * j >= kN) break;
			if (i % j == 0) {
				mu[i * j] = 0;
				break;
			}
			else mu[i * j] = -mu[i];
		}
	}
	return ;
}

int main() {
	pre();
	int n, m;
	ll ans = 0, l, r;
	scanf("%d%d", &n, &m);
	for (int d = 1; d < n; d++) {
		l = -(((n - 1) / d) * ((n - 1) / d + 1)) / 2;
		r = -(((m - 1) / d) * ((m - 1) / d + 1)) / 2;
		l *= d;
		r *= d;
		l += n * ((n - 1) / d);
		r += m * ((m - 1) / d);
		l %= kMod;
		r %= kMod;
		ans += l * r * mu[d] % kMod;
	}
	ans = ans * 2 % kMod;
	if (ans < 0) ans += kMod;
	ans += (n - 1) * m % kMod + (m - 1) * n % kMod;
	ans %= kMod;
	printf("%lld\n", ans);
}
0