195832025-12-16 10:00:24markfsibianSorozat generáláscpp17Forditási hiba
#include <iostream>
#include <deque>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>

using namespace std;

vector<int> v;

long long m, st, a, b, l, k, mini = INT_MAX;

int newn(int start)
{
    deque<char> s;
    int res = 0;
    start = start * a + b;
    
    while (start > 0)
    {
        s.push_front(start % 10);
        start = start / 10;
    }
    for (int i = s.size(); i <= m*4-1; ++i)
        s.push_front(0);
    for (int i = m; i <= 3 * m-1; ++i)
        res = res * 10 + s[i];
    return res;
}

void addns(int st1, int l)
{
    if (l > 0)
    {
        int a;
        a = newn(st1);
        if (find(v.begin(), v.end(), a) == v.end())
        {
            v.push_back(a);
            addns(a, l - 1);
        }
    }
}

int main()
{
    cin >> m >> st >> a >> b >> l >> k;
    addns(st, l);
    cout << endl;
    for (int i = 0; i < l; ++i)
    {
        auto elem = find(v.begin() + i+1, v.end(), v[i]);
        if (elem != v.end())
            mini = min(distance(v.begin(), elem) - i, mini);
    }
    cout << mini;
    cout << endl;
    sort(v.rbegin(), v.rend());
    cout << v[k-1];
}
Forditási hiba
open /var/local/lib/isolate/420/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:55:23: error: no matching function for call to 'min(std::__iterator_traits<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, void>::difference_type, long long int&)'
   55 |             mini = min(distance(v.begin(), elem) - i, mini);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/string:50,
                 from /usr/include/c++/12/bits/locale_classes.h:40,
                 from /usr/include/c++/12/bits/ios_base.h:41,
                 from /usr/include/c++/12/ios:42,
                 from /usr/include/c++/12/ostream:38,
                 from /usr/include/c++/12/iostream:39,
                 from main.cpp:1:
/usr/include/c++/12/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/12/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
main.cpp:55:23: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   55 |             mini = min(distance(v.begin(), elem) - i, mini);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/12/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/12/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
main.cpp:55:23: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   55 |             mini = min(distance(v.begin(), elem) - i, mini);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/algorithm:61,
                 from main.cpp:3:
/usr/inc...