fork download
  1. //mult(a,b) returns (a*b)%MOD
  2. //add(a,b) returns (a+b)%MOD
  3. //MOD=1000000009, C=115381398 or 276147934
  4. int hsh(string s, int id)
  5. {
  6. int ans=0;
  7. for(int i=0;i<s.length();i++)
  8. {
  9. ans=mult(ans,C);
  10. ans=add(ans,s[i]-'a'+1);
  11. }
  12. return ans;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:9: error: ‘string’ was not declared in this scope
 int hsh(string s, int id)
         ^~~~~~
prog.cpp:4:9: note: suggested alternative: ‘struct’
 int hsh(string s, int id)
         ^~~~~~
         struct
prog.cpp:4:19: error: expected primary-expression before ‘int’
 int hsh(string s, int id)
                   ^~~
prog.cpp:4:25: error: expression list treated as compound expression in initializer [-fpermissive]
 int hsh(string s, int id)
                         ^
stdout
Standard output is empty