AtCoder Beginner Contest 178

编程入门 行业动态 更新时间:2024-10-10 04:24:23

AtCoder <a href=https://www.elefans.com/category/jswz/34/1770840.html style=Beginner Contest 178"/>

AtCoder Beginner Contest 178

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300300 points

Problem Statement

How many integer sequences A1,A2,…,ANA1,A2,…,AN of length NN satisfy all of the following conditions?

  • 0≤Ai≤90≤Ai≤9
  • There exists some ii such that Ai=0Ai=0 holds.
  • There exists some ii such that Ai=9Ai=9 holds.

The answer can be very large, so output it modulo 109+7109+7.

Constraints

  • 1≤N≤1061≤N≤106
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer modulo 109+7109+7.


Sample Input 1 Copy

Copy

2

Sample Output 1 Copy

Copy

2

Two sequences {0,9}{0,9} and {9,0}{9,0} satisfy all conditions.


Sample Input 2 Copy

Copy

1

Sample Output 2 Copy

Copy

0

Sample Input 3 Copy

Copy

869121

Sample Output 3 Copy

Copy

2511445

思路:

A = 不包含9的 = 9^n

B = 不包含0的 = 9^n

AB = 不包含9的也不包含0的 = 8^n

A + B = 不包含9的或不包含0的  A+ B = A + B - AB

全部的10^n

既包含9也包含0的 = 10^n - (A + B) = 10^n - 9^n - 9^n + 8^n

code:
 

#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define N 100003
#define mod 1000000007
#define pb push_back
#define x first
#define y second
#define ull unsigned long long
#define ll long long
using namespace std;
ll n;
ll powmod(ll x)
{ll res = 1;for(int i = 1;i <= n;i++){res = res * x % mod ;}return res;
}
int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);cin >> n;ll ans = powmod(10) - powmod(9) - powmod(9) + powmod(8);ans = ans % mod;ans = (ans + mod) % mod;cout << ans << endl;return 0;
}

 

 

 

更多推荐

AtCoder Beginner Contest 178

本文发布于:2024-02-14 02:39:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1761592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Beginner   AtCoder   Contest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!