fork(1) download
  1. #include<bits/stdc++.h>
  2. #include<fstream>
  3. #define fi(i,a,b) for(int i=(a);i<(b);i++)
  4. #define fd(i,a,b) for(int i=(a);i>(b);--i)
  5. #define llu long long unsigned
  6. using namespace::std;
  7.  
  8. typedef vector <int> vi; //The following operations are defined for iterators: get value of an iterator, int x = *it; , increment and decrement iterators it1++, it2--; , compare iterators by '!=' and by '<' , add an immediate to iterator it += 20; <=> shift 20 elements forward , get the distance between iterators, int n = it2-it1; , Not only can they operate on any container, they may also perform, for example, range checking and profiling of container usage.
  9. //The type of iterator can be constructed by a type of container by appending “::iterator”, “::const_iterator”, “::reverse_iterator” or “::const_reverse_iterator” to it. use '!=' instead of '<', and 'empty()' instead of 'size() != 0' -- for some container types, it’s just very inefficient to determine which of the iterators precedes another.
  10. typedef vector<vi> vvi; //vector< vector<int> > Matrix(N, vector<int>(M, -1));
  11. typedef pair < int, int > ii; //Pairs are compared first-to-second element. If the first elements are not equal, the result will be based on the comparison of the first elements only; the second elements will be compared only if the first ones are equal. The array (or vector) of pairs can easily be sorted by STL internal functions.(convex hull - For example, if you want to sort the array of integer points so that they form a polygon, it’s a good idea to put them to the vector< pair<double, pair<int,int> >, where each element of vector is { polar angle, { x, y } }. One call to the STL sorting function will give you the desired order of points. )
  12. typedef vector < ii > vii;
  13. typedef vector <vii> vvii;
  14. vector<llu> dp(200020, 0);
  15. int main()
  16. {
  17. // freopen("in.txt", "r", stdin);
  18. string s;
  19. vector<llu> arr(200020);
  20. cin>>s;
  21. fi(i, 0, s.size())
  22. arr[i] = s[i] - '0';
  23. //fi(i, 0, s.size())
  24. //cout<<arr[i];
  25. //cout<<endl;
  26. llu sum = 0;
  27. fi(i, 0, s.size())
  28. {
  29. dp[i] = arr[i];
  30. sum = sum % 1000000007;
  31. sum += dp[i];
  32.  
  33. fi(j, i+1, s.size())
  34. {
  35. dp[j] = ((dp[j-1]% 1000000007)*10 + arr[j] ) % (1000000007);
  36. sum += dp[j];
  37. // cout<<i<<' '<<j<<' '<<dp[j]<<endl;
  38. }
  39. }
  40. cout<<sum<<endl;
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3460KB
stdin
123
stdout
164