Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. // =========== zad 2 add ===========
  2. int t, flag = 0;
  3. cout<< "Enter t"<<endl;
  4. cin >> t;
  5. vector<int> ans;
  6. for (int i=0; i<t; i++){
  7.     string s1,s2, current;
  8.     int m,l,sum_len=0;
  9. cin>>l >>m;
  10. cin>>s1;
  11. cin>>s2;
  12. //cout << s1<<"  "<<s2<<"   "<<l<<"  "<<m;
  13. //the first case without intersection
  14. sum_len = s1.length()+s2.length();
  15. //cout << sum_len;
  16. if(l - sum_len>=0){
  17.    ans.push_back((2*my_pow(26,l-sum_len,m))%m);
  18. } else{
  19.  
  20. //    if(is_equal(s1,s2,(l-sum_len))){
  21. //       flag ++;
  22. //    }
  23. //   if(is_equal(s1,s2,(l-sum_len))){
  24. //           flag ++;
  25. //       }
  26.  
  27.     ans.push_back((is_equal(s1,s2,(sum_len-l))+is_equal(s2,s1,(sum_len-l)))%m);
  28. //    if(flag){
  29. //        ans.push_back(2);
  30. //    } else{
  31. //        ans.push_back(0);
  32. //    }
  33. }
  34.  
  35. //cout<<(2*my_pow(26,1000000000,1435))%1435;
  36. }
  37.     for (int i = 0; i < t; i++){
  38.         cout<<ans[i] << endl;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement