zoukankan      html  css  js  c++  java
  • 「题解」Codeforces 468C Hack it!

    被构造橄榄了/ll

    (i<10^{18}) 时,有 (f(i)=f(i+10^{18})+1)

    (s=sum_{i=1}^{10^{18}}f(i)),根据结论,可以归纳证明 (sum_{i=1+b}^{10^{18}+b}f(i)=s+bpmod a),所以当 (b=-spmod a) 的时候,构造 (L=1+b,r=10^{18}+b) 即可满足条件。

    如何求出 (s)?求 (sum_{i=1}^{10^{18}-1})(+1) 即可得到。

    考虑任意一位数的贡献,其为 ((0+1+2+3+...+9) imes 10^{17}),一共有 (18) 位,所以 (s=45 imes 18 imes 10^{17}=81 imes 10^{18})

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<vector>
    #define pb emplace_back
    #define mp std::make_pair
    #define fi first
    #define se second
    typedef long long ll;
    typedef std::pair<int, int> pii;
    typedef std::pair<ll, int> pli;
    typedef std::pair<ll, ll> pll;
    typedef std::vector<int> vi;
    typedef std::vector<ll> vll;
    const ll mod = 998244353;
    ll Add(ll x, ll y) { return (x+y>=mod) ? (x+y-mod) : (x+y); }
    ll Mul(ll x, ll y) { return x * y % mod; }
    ll Mod(ll x) { return x < 0 ? (x + mod) : (x >= mod ? (x-mod) : x); }
    ll cadd(ll &x, ll y) { return x = (x+y>=mod) ? (x+y-mod) : (x+y); }
    template <typename T> T Max(T x, T y) { return x > y ? x : y; }
    template <typename T> T Min(T x, T y) { return x < y ? x : y; }
    template <typename T>
    T &read(T &r) {
    	r = 0; bool w = 0; char ch = getchar();
    	while(ch < '0' || ch > '9') w = ch == '-' ? 1 : 0, ch = getchar();
    	while(ch >= '0' && ch <= '9') r = r * 10 + (ch ^ 48), ch = getchar();
    	return r = w ? -r : r;
    }
    ll a, b, s = 1000000000000000000ll;
    signed main() {
    	read(a); s %= a; b = a-(s*9%a*9%a+1)%a;
    	printf("%lld %lld
    ", b+1, b+1000000000000000000ll);
    	return 0;
    }
    
  • 相关阅读:
    colock
    ToggleButton 和 Switch
    radioButon的使用
    kotlin中val和var的区别
    textEdit
    c++ 网络编程基础
    网格布局 GridLayout
    数组、指针和引用
    Hello Word
    Win7-U盘安装出现"We were unable to copy your files. "
  • 原文地址:https://www.cnblogs.com/do-while-true/p/15494524.html
Copyright © 2011-2022 走看看