ამოხსნების სტატუსი

ამ გვერდზე თქვენ იხილავთ გაგზავნილი ამოხსნების სტატუსს.


გაგზავნის თარიღი: 05.04.2021 21:02:13

ამოცანა: ციფრები ფიბონაჩის მიმდევრობაში

მომხმარებელი: mole

ვერდიქტი: ამოუხსნელი

შეფასება: 0 ქულა







#include <iostream>
#include <string>
using namespace std; 

string bigAB(string s1, string s2) {
  int i,n1,n2,k,b=0;
  string s,answer="";
  vector<char> v_sum;
  
  n1=s1.length();
  n2=s2.length();
  if(n1 < n2) {
  	s=s1;
  	s1=s2;
  	s2=s;
  	n1=s1.length();
    n2=s2.length();
  }
  
  for(i=0; i<n1; i++) {
  	int s1i=s1[n1-1-i]-48;
  	int s2i=0;
  	if(n2-1-i >= 0) s2i=s2i=s2[n2-1-i]-48;
  	k=s1i+s2i+b;
  	if(k>9) b=1;
  	else b=0;
  	v_sum.push_back(k%10);
  }
  if(b == 1) v_sum.push_back(1);
  
  for(i = v_sum.size()-1; i>=0; i--) answer+=(v_sum[i]+48);
  
  return answer;
  }
   
 int main() { 

	int i,n,k=0,h=0,j,k1=0,r,t;
	 
	string s="",a="1",b="1",c;
	cin>>n;
	
	s+=a+b
   
   do {   	 
   	 c=bigAB(a,b);
   	 a=b;
   	 b=c;  	 
   	 
   	 s+=c; 	 
	    	 
   } while(s.size() < n)
   
   cout<<s[n-1];
    
} 
PROB_cpp_UID1373PID474_43584b/main.cpp: In function 'std::__cxx11::string bigAB(std::__cxx11::string, std::__cxx11::string)':
PROB_cpp_UID1373PID474_43584b/main.cpp:8:3: error: 'vector' was not declared in this scope
   vector<char> v_sum;
   ^~~~~~
PROB_cpp_UID1373PID474_43584b/main.cpp:8:10: error: expected primary-expression before 'char'
   vector<char> v_sum;
          ^~~~
PROB_cpp_UID1373PID474_43584b/main.cpp:27:4: error: 'v_sum' was not declared in this scope
    v_sum.push_back(k%10);
    ^~~~~
PROB_cpp_UID1373PID474_43584b/main.cpp:29:14: error: 'v_sum' was not declared in this scope
   if(b == 1) v_sum.push_back(1);
              ^~~~~
PROB_cpp_UID1373PID474_43584b/main.cpp:31:11: error: 'v_sum' was not declared in this scope
   for(i = v_sum.size()-1; i>=0; i--) answer+=(v_sum[i]+48);
           ^~~~~
PROB_cpp_UID1373PID474_43584b/main.cpp: In function 'int main()':
PROB_cpp_UID1373PID474_43584b/main.cpp:45:4: error: expected ';' before 'do'
    do {
    ^~