fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. //map<string,ll> mp ;
  5. //map<string,ll> :: iterator itr;
  6.  
  7. int main()
  8. {
  9. string s,str; ll k,b,m,ans=0,p,base;
  10. cin>>s;
  11. cin>>k>>b>>m;
  12. str=s.substr(0,k);
  13. base=stoll(str,nullptr,b);
  14. base=base%m;
  15. ans+=base;
  16. //mp[str]=base;
  17.  
  18. for(ll i=k;i<s.length();i++){
  19. str.erase(0,1);
  20. str+=s[i];
  21.  
  22. //itr=mp.find(str);
  23. //if(itr==mp.end()){
  24. base=stoll(str,nullptr,b);
  25. base=base%m;
  26. ans+=base;
  27. //mp[str]=base;
  28. //}
  29. //else{
  30. //ans+=itr->second;
  31. //}
  32. }
  33. cout<<ans<<endl;
  34. return 0;
  35. }
  36.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
12212
3 3 5
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13: error: 'nullptr' was not declared in this scope
prog.cpp:13: error: 'stoll' was not declared in this scope
stdout
Standard output is empty