dimanche 23 août 2020

What is solution for error in vector in C++?

/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
    int num;
    cin >> num;                                     // Reading input from STDIN
    cout << "Input number is " << num << endl;      // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>  
using namespace std;
typedef long long int ll;
vector<ll> v;
void make(ll num)
{
    if(num>10000000000)
        return ;
    if(num!=0)
        v.insert(num);
     make(num*10+4);
     make(num*10+7);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll num=0;
    make(num);
    ll n,ans=0;
    cin>>n;
    for(auto i:v)
    {
        for(auto j:v)
        {
            if(i<=n&&j<=n&&j>=i)
            {
                if(__gcd(i,j)==1)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Error:

In function 'void make(ll)':
30:21: error: no matching function for call to 'std::vector<long long int>::insert(ll&)'


69:0,
20:
114:5: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::value_type = long long int]
:

114:5: note:   candidate expects 2 arguments, 1 provided
64:0,
20:
1042:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::value_type = long long int]


1042:7: note:   candidate expects 2 arguments, 1 provided
1059:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*]


1059:7: note:   candidate expects 2 arguments, 1 provided
1084:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = long long int]


1084:7: note:   candidate expects 3 arguments, 1 provided
1128:2: note: candidate: template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = long long int; _Alloc = std::allocator<long long int>]


1128:2: note:   template argument deduction/substitution failed:
30:21: note:   candidate expects 3 arguments, 1 provided<br>

How to solve the problem

Aucun commentaire:

Enregistrer un commentaire