QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605063#9225. Fibonacci Fusion2jogger1WA 139ms166532kbC++141.6kb2024-10-02 15:18:332024-10-02 15:18:34

Judging History

你现在查看的是最新测评结果

  • [2024-10-02 15:18:34]
  • 评测
  • 测评结果:WA
  • 用时:139ms
  • 内存:166532kb
  • [2024-10-02 15:18:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int mod[2] = {1000000009, 998244353};
const int N = 2e7 + 10;

void solve() {
	int n;
	cin >> n;
	vector<string> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end(), [&](string s, string t) {
		if(s.size() != t.size()) {
			return s.size() < t.size();
		}
		return s < t;
	});
	vector<pii> f(N);
	f[0] = {0, 0}, f[1] = {1, 1};
	for(int i = 2; i < N; i++) {
		f[i].first = (f[i - 1].first + f[i - 2].first) % mod[0];
		f[i].second = (f[i - 1].second + f[i - 2].second) % mod[1];	
	}
	map<pii, int> mp;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ll res0 = 0, res1 = 0;
		int l = v[i].size();
		for(int j = 0; j < l; j++) {
			res0 = (res0 * 10 + v[i][j] - '0') % mod[0];
			res1 = (res1 * 10 + v[i][j] - '0') % mod[1];
		}
		int index = (log10(sqrt(5)) + log10(v[i][0] - '0') + l - 1) / log10((sqrt(5) + 1) / 2);
		if(l == 1) {
			if(v[i][0] == '1') {
				index = 2;
			} else if(v[i][0] == '2') {
				index = 3;
			} else if(v[i][0] == '3') {
				index = 4;
			} else if(v[i][0] <= '5') {
				index = 5;
			} else if(v[i][0] <= '8') {
				index = 6;
			} else {
				index = 7;
			}
		}
		for(int j = 0; j <= 5; j++) {
			int nd1 = (f[index + j].first - res0 + mod[0]) % mod[0];
			int nd2 = (f[index + j].second - res1 + mod[1]) % mod[1];
			ans += mp[{nd1, nd2}];
		}
		mp[{res0, res1}]++;
	}
	cout << ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 85ms
memory: 159584kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 115ms
memory: 164592kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: 0
Accepted
time: 129ms
memory: 166532kb

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:

6073

result:

ok 1 number(s): "6073"

Test #4:

score: -100
Wrong Answer
time: 139ms
memory: 165784kb

input:

200000
2
2
2
2
1
2
1
1
2
2
1
1
1
2
2
1
1
2
1
1
2
2
1
2
2
2
1
1
1
1
2
2
1
2
1
2
1
1
2
2
1
1
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
1
2
1
1
1
1
1
2
1
2
2
1
1
1
2
2
2
1
1
2
1
1
2
1
2
1
1
1
2
2
2
1
1
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
2
1
2
1
2
2
1
1
2
1
1
1
2
2
2
1
2
2
1
1
2
2
2
2
1
2
1
1
2
1
2
2
1
1
1
1
2
2
2
2...

output:

2118847371

result:

wrong answer 1st numbers differ - expected: '15003749259', found: '2118847371'