Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************
- * ####### # *
- * # # # ###### # # # # #### # # # # # *
- * # # # # # # ## # # # # # # # *
- * # ###### ##### # # # # # #### ###### # # # *
- * # # # # ####### # # # # # # # # # *
- * # # # # # # # ## # # # # # # # *
- * # # # ###### # # # # #### # # #### ###### *
- ***************************************************************************/
- #include<bits/stdc++.h>
- #define ll long long
- #define pb push_back
- #define endl '\n'
- #define pii pair<ll int,ll int>
- #define vi vector<ll int>
- #define all(a) (a).begin(),(a).end()
- #define F first
- #define S second
- #define sz(x) (ll int)x.size()
- #define hell 1000000007
- #define rep(i,a,b) for(ll int i=a;i<b;i++)
- #define lbnd lower_bound
- #define ubnd upper_bound
- #define bs binary_search
- #define mp make_pair
- using namespace std;
- #define N 100005
- ll expo(ll base, ll exponent, ll mod) { //return base^exponent modulo modulus
- ll ans = 1;
- while(exponent !=0 ) {
- if((exponent&1) == 1) {
- ans = ans*base ;
- ans = ans%mod;
- }
- base = base*base;
- base %= mod;
- exponent>>= 1;
- }
- return ans%mod;
- }
- ll gcd(ll a, ll b) { //return gcd of a,b
- if (a == 0) return b;
- return gcd(b%a, a);
- }
- ll modInv(ll a, ll m) { //return modulo inverse of a w.r.t. m
- ll gc=gcd(a,m);
- a/=gc;m/=gc;
- ll m0=m,y=0,x=1;
- if (m == 1) return 0;
- while (a > 1) {
- ll q=a/m,t=m;
- m = a % m, a = t;
- t = y;
- y = x - q * y;
- x = t;
- }
- if (x < 0) x += m0;
- return x;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int TESTS=1;
- // cin>>TESTS;
- while(TESTS--)
- {
- string s;
- cin>>s;
- ll n=s.length();
- ll sum=0;
- ll intr;
- rep(r,0,n)
- {
- intr=(s[n-1-r]-'0');
- intr=(intr*(n-r))%hell;
- intr=(intr*(expo(10,r+1,hell) - 1))%hell;
- sum+=intr;
- sum=sum%hell;
- }
- sum=(sum*modInv(9,hell))%hell;
- cout<<sum%hell;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement