1
/* // 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

10
  • 1
    the function iterator insert( iterator pos, const T& value ); takes in an iterator and the value Commented Aug 23, 2020 at 18:11
  • There is no function called insert in vector. What is __gcd? Is it a user-defined function created by you? Commented Aug 23, 2020 at 18:12
  • 2
    Have a look at the documentation for std::vector::insert. Commented Aug 23, 2020 at 18:16
  • 1
    @Sumeet, G.M.'s comment contains a link that proves you wrong. Commented Aug 23, 2020 at 18:20
  • 2
    typedef long long int ll; -- I see this crazy macro too often. Why not simply use int64_t instead of this? It is more descriptive of exactly the type of integer you want to use, and isn't something that looks like the number 11. Commented Aug 23, 2020 at 18:26

2 Answers 2

7

In function make(), try using v.push_back(num) instead of v.insert(num) it should work.

Sign up to request clarification or add additional context in comments.

Comments

1

You lack the first parameter in your vector::insert, the position the new element should be placed after. If you don't want to use vector::push_back as suggested in the previous answer, here is a MWE:

#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(v.begin(),num); // iterator to insert position added 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; cout << "Input number: " << endl; cin>>n; for(auto i:v) { for(auto j:v) { if(i<=n&&j<=n&&j>=i) { if(__gcd(i,j)==1) ans++; } } } cout<< "answer = " << ans <<endl; return 0; } 

What is this for? A random number generator?

1 Comment

find coprime where two number consist of only '4' and '7'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.