MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Codeforces_problems/Bargain/solution.cpp:65–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65int main(int /* argc */, char** /* argv */)
66{
67 ios_base::sync_with_stdio(false);
68 cin.tie(NULL);
69#ifdef LOCAL
70 assert(freopen("i.txt", "r", stdin));
71 assert(freopen("o.txt", "w", stdout));
72#endif
73
74 string s;
75 cin >> s;
76
77 int n = s.size();
78 vector<ll> a(n);
79 for (int i = 0; i < n; ++i) {
80 a[i] = s[i] - '0';
81 }
82
83 const int MOD = (int)1e+9 + 7;
84
85 ll ans = 0;
86 ll sum = 0;
87 ll p = 1;
88
89 for (ll i = n - 1; i >= 0; --i) {
90 ll k = (i * (i + 1) / 2 % MOD * p % MOD + sum) % MOD;
91 sum = (sum + p * (n - i) % MOD) % MOD;
92 p = p * 10 % MOD;
93 ans = (ans + a[i] * k % MOD) % MOD;
94 }
95
96 cout << ans << endl;
97
98#ifdef LOCAL
99 cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
100#endif
101 return 0;
102}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected