Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =========== zad 2 add ===========
- int t, flag = 0;
- cout<< "Enter t"<<endl;
- cin >> t;
- vector<int> ans;
- for (int i=0; i<t; i++){
- string s1,s2, current;
- int m,l,sum_len=0;
- cin>>l >>m;
- cin>>s1;
- cin>>s2;
- //cout << s1<<" "<<s2<<" "<<l<<" "<<m;
- //the first case without intersection
- sum_len = s1.length()+s2.length();
- //cout << sum_len;
- if(l - sum_len>=0){
- ans.push_back((2*my_pow(26,l-sum_len,m))%m);
- } else{
- // if(is_equal(s1,s2,(l-sum_len))){
- // flag ++;
- // }
- // if(is_equal(s1,s2,(l-sum_len))){
- // flag ++;
- // }
- ans.push_back((is_equal(s1,s2,(sum_len-l))+is_equal(s2,s1,(sum_len-l)))%m);
- // if(flag){
- // ans.push_back(2);
- // } else{
- // ans.push_back(0);
- // }
- }
- //cout<<(2*my_pow(26,1000000000,1435))%1435;
- }
- for (int i = 0; i < t; i++){
- cout<<ans[i] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement