Untitled
unknown
plain_text
5 months ago
1.2 kB
2
Indexable
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); const long long val = 1e18; long long fib[90]; int final_one = 0; pair<long long ,long long> get(long long i, long long index) { if (i <= 2) return {i, index}; if (i > final_one) return get(i - 1, index); if (index <= fib[i - 1]) return get(i - 1, index); return get(i - 2, index - fib[i - 1]); } void solve() { int n, m; cin >> n >> m; string s[2]; cin >> s[0] >> s[1]; long long x, k; cin >> x >> k; fib[1] = n; fib[2] = m; for (int i = 3; i < 90; ++i) { fib[i] = fib[i - 1] + fib[i - 2]; if (fib[i] >= val) { final_one = i; break; } } pair<long long, long long> ans = get(x, k); cout << s[ans.first - 1][ans.second - 1]; } int main() { fast; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("Error.txt", "w", stderr); #endif int t = 1; cin >> t; for (int i = 1 ; i <= t; ++i) { solve(); if (i != t) cout << '\n'; } return 0; }
Editor is loading...
Leave a Comment