D - 88888888
https://atcoder.jp/contests/abc357/tasks/abc357_d
思路
Code
https://atcoder.jp/contests/abc357/submissions/54384091
LL n; LL base = 998244353; LL getlen(LL n){ LL cnt = 0; while(n){ cnt++; n /= 10; } return cnt; } LL ksm(LL a, LL b) { LL t = 1; while (b) { if (b & 1) t = t * a % base; a = a * a % base, b >>= 1; } return t; } int main() { cin >> n; LL len = getlen(n); // cout << len << endl; LL powsum = 0,powone; if(len==19){ powone=((LL)ksm(10,18)%base)*10%base; } else{ powone = ksm(10, len); } powone %= base; // LL powi = 1; // for(LL i=0; i<n; i++){ // if (i == 0){ // powi = 1; // } else { // powi *= powone; // powi %= base; // } // // powsum += powi; // powsum %= base; // } powsum = (ksm(powone, n)%base -1)%base; powsum = powsum*ksm(powone-1,base-2)%base; LL sum = (n%base)*powsum; sum %= base; cout << sum << endl; return 0; }
标签:cnt,88888888,LL,base,abc357,contests From: https://www.cnblogs.com/lightsong/p/18239082