fork(3) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <sstream>
  5. #include <cmath>
  6. #include <cstdio>
  7. #include <string>
  8. #include <vector>
  9. #include <algorithm>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <map>
  13. #include <queue>
  14. #include <set>
  15. #include <queue>
  16. #include <stack>
  17. #include <deque>
  18. #include <assert.h>
  19. #include <ctime>
  20. #include <bitset>
  21. #include <numeric>
  22. #include <complex>
  23. #include <valarray>
  24. #define MAX 100001
  25. #define MOD 1000003
  26. #define ll long long
  27. using namespace std;
  28.  
  29.  
  30.  
  31. int main(){
  32.  
  33. ios_base :: sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
  34.  
  35. map<char, string> map;
  36.  
  37. string input, ans;
  38.  
  39. ll i, x, len, val=0, pw;
  40.  
  41.  
  42. map['>'] = "1000" ; map['<'] = "1001" ; map['+'] = "1010" ; map['-'] = "1011" ;
  43. map['.'] = "1100" ; map[','] = "1101" ; map['['] = "1110" ; map[']'] = "1111" ;
  44.  
  45. cin >> input;
  46.  
  47. for(i = 0; i < input.size(); ++i) {
  48.  
  49. ans += map[input[i]];
  50. }
  51.  
  52. len = ans.length();
  53.  
  54. x=len - 1;
  55.  
  56. for(i=len - 1; i >= 0; --i) {
  57.  
  58. pw = pow(2,x - i) ;
  59.  
  60. if(ans[i] == '1') val = (val%MOD + pw % MOD)%MOD;
  61.  
  62. }
  63.  
  64.  
  65.  
  66. cout << val <<"\n";
  67.  
  68. return 0;
  69.  
  70.  
  71. }
Success #stdin #stdout 0s 16056KB
stdin
[-],<],<<,<[,>,+>[[<>.,[>-[-[<><>><<<<]>,.-].>-[[>+,>,[,-,.-,-[[]>..<>,<[+,-<]-++.<+.]<,[[.<<-><<<],
stdout
-758993