fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int doStuffs(int mid,int a){
  5. //your code here
  6. if(mid==1){return -1;}
  7. if((mid*mid)==a){
  8. cout<< mid;
  9.  
  10. }
  11.  
  12. else{
  13. mid=mid/2;
  14. return doStuffs(mid-1,a);
  15. if(doStuffs(mid-1,a)==-1){return doStuffs(mid+1,a);}
  16. }
  17.  
  18.  
  19. }
  20. int doStuff(int a){
  21. //your code here
  22. int mid=a/2;
  23. if(mid*mid==a){
  24. return mid;
  25.  
  26. }
  27. else{
  28. return doStuffs(mid-1,a);
  29. }
  30. }
  31.  
  32. int main(){
  33.  
  34. doStuff(25);
  35. }
Success #stdin #stdout 0s 3408KB
stdin
25
stdout
Standard output is empty