Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <math.h>
- #include <algorithm>
- #include <stdlib.h>
- #include <string>
- #include <sstream>
- using namespace std;
- ifstream in;
- ofstream out("output.txt");
- template<class T>
- string toString (const T& t) {
- stringstream ss;
- ss << t;
- return ss.str();
- }
- int main()
- {
- in.open("input.txt");
- int N;
- in>>N;
- string num1,key;
- long long int num[N];
- in>>num1;
- in.close();
- in.open("input.txt");
- in>>N;
- for(int i=0;i<N;i++)
- in>>num[i];
- key=toString(num[0]);
- int j=1;
- // 12345 12345
- for(int i=0;i<N;i++)
- {
- while(num[i]!=num[j] &&j<N)
- {
- for(int k=0;k<N;k++){ num[k]/=10;}
- }
- if(num[i]==num[j] )
- j++;
- }
- j=0;
- while(num[0]>0)
- {
- num[0]/=10;
- j++;
- }
- j+=num1.size()-key.size();
- cout<<j;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement