Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <algorithm>
  5. #include <stdlib.h>
  6. #include <string>
  7. #include <sstream>
  8. using namespace std;
  9.  
  10. ifstream in;
  11. ofstream out("output.txt");
  12.  
  13. template<class T>
  14. string toString (const T& t) {
  15.     stringstream ss;
  16.     ss << t;
  17.     return ss.str();
  18. }
  19.  
  20. int main()
  21. {
  22.    
  23.     in.open("input.txt");
  24.     int N;
  25.     in>>N;
  26.    
  27.     string num1,key;
  28.    
  29.     long long int num[N];
  30.    
  31.     in>>num1;
  32.    
  33.     in.close();
  34.     in.open("input.txt");
  35.    
  36.     in>>N;
  37.    
  38.     for(int i=0;i<N;i++)
  39.             in>>num[i];
  40.    
  41.     key=toString(num[0]);  
  42.    
  43.    
  44.     int j=1;   
  45.        
  46.        
  47.    
  48.  
  49.     // 12345 12345
  50. for(int i=0;i<N;i++)
  51. {
  52.    
  53.         while(num[i]!=num[j] &&j<N)
  54.         {
  55.             for(int k=0;k<N;k++){ num[k]/=10;}
  56.         }
  57.         if(num[i]==num[j] )
  58.             j++;
  59.            
  60. }  
  61. j=0;
  62.  
  63.     while(num[0]>0)
  64.     {
  65.         num[0]/=10;
  66.         j++;
  67.     }
  68.  
  69. j+=num1.size()-key.size();
  70.  
  71.    
  72.    
  73.    
  74.     cout<<j;
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement