Advertisement
TheAnshul

Sam and substtrings

Jun 9th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. /***************************************************************************
  2. * ####### # *
  3. * # # # ###### # # # # #### # # # # # *
  4. * # # # # # # ## # # # # # # # *
  5. * # ###### ##### # # # # # #### ###### # # # *
  6. * # # # # ####### # # # # # # # # # *
  7. * # # # # # # # ## # # # # # # # *
  8. * # # # ###### # # # # #### # # #### ###### *
  9. ***************************************************************************/
  10. #include<bits/stdc++.h>
  11. #define ll long long
  12. #define pb push_back
  13. #define endl '\n'
  14. #define pii pair<ll int,ll int>
  15. #define vi vector<ll int>
  16. #define all(a) (a).begin(),(a).end()
  17. #define F first
  18. #define S second
  19. #define sz(x) (ll int)x.size()
  20. #define hell 1000000007
  21. #define rep(i,a,b) for(ll int i=a;i<b;i++)
  22. #define lbnd lower_bound
  23. #define ubnd upper_bound
  24. #define bs binary_search
  25. #define mp make_pair
  26. using namespace std;
  27.  
  28. #define N 100005
  29.  
  30. int main()
  31. {
  32. ios_base::sync_with_stdio(false);
  33. cin.tie(0);
  34. cout.tie(0);
  35. int TESTS=1;
  36. // cin>>TESTS;
  37. while(TESTS--)
  38. {
  39. string s;
  40. cin>>s;
  41. ll n=s.length();
  42. vi dp(n);
  43. ll sum=0;
  44. dp[0]=s[0]-'0';
  45. sum+=dp[0];
  46. rep(i,1,n)
  47. {
  48. dp[i]=(10*dp[i-1]+(i+1)*(s[i]-'0'))%hell;
  49. sum=(sum+dp[i])%hell;
  50. }
  51. cout<<sum%hell;
  52. }
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement