Detalii evaluare #53990645

Rezumat problemă

#2653 nroot C++

Scrieți un subprogram care primește doi parametri, n și x, și care returnează valoarea absolută radicalului de ordin n din x.

Detalii

Problema nroot Operații I/O tastatură/ecran
Limita timp 0.01 secunde Limita memorie Total: 8 MB / Stivă 4 MB
Id soluție #53990645 Utilizator Stefan Matei (MatthewRo)
Fișier nroot.cpp Dimensiune 201 B
Data încărcării 17 Noiembrie 2024, 09:12 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

nroot.cpp: In function 'long long int nroot(int, long long int)':
nroot.cpp:9:16: error: no matching function for call to 'sqrt(long long int&, int&)'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                ^
nroot.cpp:9:16: note: candidates are:
In file included from /usr/include/features.h:374:0,
                 from /usr/include/assert.h:35,
                 from /usr/include/c++/4.8/cassert:43,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:33,
                 from nroot.cpp:1:
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note: double sqrt(double)
 __MATHCALL (sqrt,, (_Mdouble_ __x));
 ^
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Tp> std::_Expr<std::_UnClos<std::_Sqrt, std::_ValArray, _Tp>, _Tp> std::sqrt(const std::valarray<_Tp>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:16: note:   mismatched types 'const std::valarray<_Tp>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Dom> std::_Expr<std::_UnClos<std::_Sqrt, std::_Expr, _Dom>, typename _Dom::value_type> std::sqrt(const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:16: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from nroot.cpp:1:
/usr/include/c++/4.8/complex:892:5: note: template<class _Tp> std::complex<_Tp> std::sqrt(const std::complex<_Tp>&)
     sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
     ^
/usr/include/c++/4.8/complex:892:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:16: note:   mismatched types 'const std::complex<_Tp>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:494:5: note: template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp)
     sqrt(_Tp __x)
     ^
/usr/include/c++/4.8/cmath:494:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:16: note:   candidate expects 1 argument, 2 provided
     if(sqrt(x,n)>=0) return sqrt(x,n);

                ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:486:3: note: constexpr long double std::sqrt(long double)
   sqrt(long double __x)
   ^
/usr/include/c++/4.8/cmath:486:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/4.8/cmath:482:3: note: constexpr float std::sqrt(float)
   sqrt(float __x)
   ^
/usr/include/c++/4.8/cmath:482:3: note:   candidate expects 1 argument, 2 provided
nroot.cpp:9:37: error: no matching function for call to 'sqrt(long long int&, int&)'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                                     ^
nroot.cpp:9:37: note: candidates are:
In file included from /usr/include/features.h:374:0,
                 from /usr/include/assert.h:35,
                 from /usr/include/c++/4.8/cassert:43,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:33,
                 from nroot.cpp:1:
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note: double sqrt(double)
 __MATHCALL (sqrt,, (_Mdouble_ __x));
 ^
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Tp> std::_Expr<std::_UnClos<std::_Sqrt, std::_ValArray, _Tp>, _Tp> std::sqrt(const std::valarray<_Tp>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:37: note:   mismatched types 'const std::valarray<_Tp>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                                     ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Dom> std::_Expr<std::_UnClos<std::_Sqrt, std::_Expr, _Dom>, typename _Dom::value_type> std::sqrt(const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:37: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                                     ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from nroot.cpp:1:
/usr/include/c++/4.8/complex:892:5: note: template<class _Tp> std::complex<_Tp> std::sqrt(const std::complex<_Tp>&)
     sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
     ^
/usr/include/c++/4.8/complex:892:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:37: note:   mismatched types 'const std::complex<_Tp>' and 'long long int'
     if(sqrt(x,n)>=0) return sqrt(x,n);

                                     ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:494:5: note: template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp)
     sqrt(_Tp __x)
     ^
/usr/include/c++/4.8/cmath:494:5: note:   template argument deduction/substitution failed:
nroot.cpp:9:37: note:   candidate expects 1 argument, 2 provided
     if(sqrt(x,n)>=0) return sqrt(x,n);

                                     ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:486:3: note: constexpr long double std::sqrt(long double)
   sqrt(long double __x)
   ^
/usr/include/c++/4.8/cmath:486:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/4.8/cmath:482:3: note: constexpr float std::sqrt(float)
   sqrt(float __x)
   ^
/usr/include/c++/4.8/cmath:482:3: note:   candidate expects 1 argument, 2 provided
nroot.cpp:10:26: error: no matching function for call to 'sqrt(long long int&, int&)'
          return -sqrt(x,n);

                          ^
nroot.cpp:10:26: note: candidates are:
In file included from /usr/include/features.h:374:0,
                 from /usr/include/assert.h:35,
                 from /usr/include/c++/4.8/cassert:43,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:33,
                 from nroot.cpp:1:
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note: double sqrt(double)
 __MATHCALL (sqrt,, (_Mdouble_ __x));
 ^
/usr/include/i386-linux-gnu/bits/mathcalls.h:156:1: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Tp> std::_Expr<std::_UnClos<std::_Sqrt, std::_ValArray, _Tp>, _Tp> std::sqrt(const std::valarray<_Tp>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:10:26: note:   mismatched types 'const std::valarray<_Tp>' and 'long long int'
          return -sqrt(x,n);

                          ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from nroot.cpp:1:
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note: template<class _Dom> std::_Expr<std::_UnClos<std::_Sqrt, std::_Expr, _Dom>, typename _Dom::value_type> std::sqrt(const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
     ^
/usr/include/c++/4.8/bits/valarray_after.h:455:5: note:   template argument deduction/substitution failed:
nroot.cpp:10:26: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'long long int'
          return -sqrt(x,n);

                          ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from nroot.cpp:1:
/usr/include/c++/4.8/complex:892:5: note: template<class _Tp> std::complex<_Tp> std::sqrt(const std::complex<_Tp>&)
     sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
     ^
/usr/include/c++/4.8/complex:892:5: note:   template argument deduction/substitution failed:
nroot.cpp:10:26: note:   mismatched types 'const std::complex<_Tp>' and 'long long int'
          return -sqrt(x,n);

                          ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:494:5: note: template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp)
     sqrt(_Tp __x)
     ^
/usr/include/c++/4.8/cmath:494:5: note:   template argument deduction/substitution failed:
nroot.cpp:10:26: note:   candidate expects 1 argument, 2 provided
          return -sqrt(x,n);

                          ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from nroot.cpp:1:
/usr/include/c++/4.8/cmath:486:3: note: constexpr long double std::sqrt(long double)
   sqrt(long double __x)
   ^
/usr/include/c++/4.8/cmath:486:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/4.8/cmath:482:3: note: constexpr float std::sqrt(float)
   sqrt(float __x)
   ^
/usr/include/c++/4.8/cmath:482:3: note:   candidate expects 1 argument, 2 provided
nroot.cpp:11:1: warning: control reaches end of non-void function [-Wreturn-type]
 }

 ^

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema nroot face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:

  • Soluția propusă de tine este inclusă în programul suport, apoi acesta este compilat. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Datorită existenței programului suport, la compilare pot să apară erori sau avertismente care să nu se refere la instrucțiunile scrise de tine, dar care sunt datorate faptului că soluția ta nu este corectă.
  • Dacă programul suport a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.