34922023-02-28 12:47:02horvathabelSorozat generáláscpp17Accepted 50/5016ms6140 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
	ll n, m, a, b,  l;
	ll k;
	cin>>m>>k>>a>>b>>l>>n;
	int cnt=0; 
	int ans=0; 
	int kis=pow(10, m);
	int nagy=pow(10,3*m);
	map<ll, ll> st; 
	vector<ll> v; 
	bool vanmego=false;
	for (int i=0; i<l;i++){
		cnt++; 
		k*=a;
		k+=b;
		k%=nagy;
		k/=kis; 
		v.push_back(k);
		if (!vanmego){
			if (st.count(k)==0){
				st[k]=cnt;
			}
			else{
				ans=cnt-st[k];
				vanmego=true;  
			}
		}

	} 
	cout<<ans<<endl;
	sort(v.begin(), v.end());
	cout<<v[l-n];
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/014ms4336 KiB
3Accepted2/23ms2344 KiB
4Accepted2/23ms2788 KiB
5Accepted2/23ms3140 KiB
6Accepted2/23ms3164 KiB
7Accepted2/23ms3320 KiB
8Accepted4/44ms3460 KiB
9Accepted4/44ms4100 KiB
10Accepted4/48ms4572 KiB
11Accepted4/48ms4632 KiB
12Accepted4/410ms5472 KiB
13Accepted4/413ms5884 KiB
14Accepted4/414ms5968 KiB
15Accepted4/413ms5856 KiB
16Accepted4/416ms5980 KiB
17Accepted4/416ms6140 KiB