BNUOJ4359 无爱编号

无爱编号

2000ms
65536KB
 
64-bit integer IO format: %lld      Java class name: Main

众所周知,拉手网有许多客户,由于客户数量实在过于庞大,因此拉手网希望为每位客户进行编号以便更好的为客户服务。每个编号为一个由‘0’~‘9’组成的N位数字。考虑到很多人不喜欢数字4和数字13,因此我们称包含4或包含13的编号为无爱编号,如134、84、121351都是无爱编号,123则不是无爱编号。现在我们希望知道,所有N位的编号中,刨除掉无爱编号后剩余的编号数量。这个编号数量可能很大,我们只要知道结果的最后8位即可。

Input

 输入的第一行是一个整数T,表示数据组数。

以下T行每行一个整数N(1 ≤ N ≤1000000),表示编号的位数。
 

Output

 对于每组数据,输出一个8位整数表示编号数量的最后8位。若编号数量不足8位则用前导零填充。

 

Sample Input

2
1
2
 

Sample Output

00000009
00000080
 

Source

Author

temperlsyer
 
 
解题:找规律即可!
 
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <vector>
 6 #include <climits>
 7 #include <algorithm>
 8 #include <cmath>
 9 #define LL long long
10 using namespace std;
11 const int md = 100000000;
12 int d[1000010] = {0,9,80};
13 int main(){
14     int i,kase,n;
15     for(i = 3; i < 1000010; i++){
16         d[i] = ((LL)d[i-1]*9 - d[i-2] + md)%md;
17     }
18     scanf("%d",&kase);
19     while(kase--){
20         scanf("%d",&n);
21         printf("%08d
",d[n]);
22     }
23     return 0;
24 }
View Code
原文地址:https://www.cnblogs.com/crackpotisback/p/3831737.html