結果

問題 No.3038 フィボナッチ数列の周期
ユーザー ats5515ats5515
提出日時 2018-04-02 01:35:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,345 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 86,372 KB
実行使用メモリ 7,508 KB
最終ジャッジ日時 2023-09-08 13:15:25
合計ジャッジ時間 7,948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 13 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 145 ms
4,376 KB
testcase_08 AC 135 ms
4,376 KB
testcase_09 AC 86 ms
4,376 KB
testcase_10 AC 244 ms
4,376 KB
testcase_11 AC 77 ms
4,380 KB
testcase_12 AC 192 ms
4,380 KB
testcase_13 AC 163 ms
4,376 KB
testcase_14 AC 211 ms
4,380 KB
testcase_15 AC 645 ms
4,380 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int solve(long long int)’:
main.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int p(int a, int b) {
	if (b == 0)return 1;
	if (b % 2 == 0) {
		return p((a*a) % MOD, b / 2);
	}
	else {
		return (p((a*a) % MOD, b / 2) * a) % MOD;
	}
}
int inv(int a) {
	return p(a, MOD - 2);
}
long long solve(long long m) {
	long long a = 0, b = 1, c = a + b;
	for (int i = 0; i < m * m; i++) {
		c = (a + b) % m;
		a = b;
		b = c;
		if (a == 0 && b == 1) return i + 1;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> pr(N);
	vector<int> k(N);
	int res = 1;
	vector<int> x;
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> pr[i] >> k[i];
		map<int, int> tmp;
		tmp[pr[i]] = k[i] - 1;
		int x = solve(pr[i]);
		//cerr << "x=" << x << endl;
		for (int j = 2; j <= x; j++) {
			if (j*j > x)j = x;
			while (x%j == 0) {
				x /= j;
				tmp[j]++;
			}
		}
		if (x != 1)cerr << "ERROR x=" << x << endl;
		for (auto m : tmp) {
			mp[m.first] = max(mp[m.first], m.second);
			//mp[m.first] += m.second;
		}
	}
	for (auto m : mp) {
		//cerr << m.first << " " << m.second << endl;
		res = (res*p(m.first, m.second)) % MOD;
	}
	cout << res << endl;
}
0