結果

問題 No.368 LCM of K-products
ユーザー kotamanegikotamanegi
提出日時 2016-04-30 00:18:05
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,532 bytes
コンパイル時間 1,142 ms
コンパイル使用メモリ 94,360 KB
実行使用メモリ 785,024 KB
最終ジャッジ日時 2024-04-15 07:52:54
合計ジャッジ時間 59,671 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define  _SCL_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cstdint>
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
using namespace std;
long long sosuu_counter[110000][1000] = {};
vector<int> whereis;
map<int,long long> hogee;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, n) {
		long long n;
		cin >> n;
		int cnt = 2;
		while (true) {
			if (n % cnt == 0) {
				sosuu_counter[cnt][i]++;
				n /= cnt;
			}
			else {
				cnt++;
				if (cnt > sqrt(n)) {
					hogee[n]++;
					whereis.push_back(n);
					goto ok;
				}
			}
		}
	ok:;
	}
	long long ans = 1;
	for (int i = 0;i < whereis.size();++i) {
		for (int q = 0;q < i;++q) {
			if (whereis[i] == whereis[q]) goto ah;
		}
		for (int q = 0;q < k && q < hogee[whereis[i]];++q) {
			ans = (ans*whereis[i]) % MAX_MOD;
		}
	ah:;
	}
	for (int i = 2;i <= 100000;++i) {
		sort(sosuu_counter[i], sosuu_counter[i] + 1000,greater<long long>());
		long long counter = 0;
		for (int q = 0;q < k;++q) {
			counter += sosuu_counter[i][q];
		}
		for (int q = 0;q < counter;++q) {
			ans = (ans*i) % MAX_MOD;
		}
	}
	cout << ans % MAX_MOD << endl;
	return 0;
}
0