容斥原理
C - Ubiquity
https://atcoder.jp/contests/abc178/tasks/abc178_c
全部-没有0的-没有9的+重复减去的值(既没有0又没有9)
#include<bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second #define bg begin() #define ed end() #define rbg rbegin() #define all(x) x.bg,x.ed #define cy cout<<"YES"<<endl #define cn cout<<"NO"<<endl #define de(x) cout<<x<<"###"<<endl using namespace std; const long long inf=2e18; typedef long long ll; typedef pair<ll,ll>pii; typedef vector<ll>vi; const double eps=1e-10; const int mod=1e9+7; const int N=2e5+5; ll ksm(int a,int b){ int res=1; while(b){ if(b&1)res=res*a%mod; a=a*a%mod; b>>=1; } return res; } void solve(){ int n; cin>>n; int ans=(ksm(10,n)-2*ksm(9,n)+ksm(8,n))%mod; ans=(ans+mod)%mod; cout<<ans<<endl; } signed main(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios::sync_with_stdio(false); cin.tie(0); //int t; //cin>>t; //while(t--){ solve(); //} return 0; }