---
# System prepended metadata

title: 'a828: 間隔數 ( number )'
tags: [蘿莉控自學]

---

---
tags: 蘿莉控自學
---
> 蘿莉控的C++自學筆記
# a828: 間隔數 ( number )
題目連結:http://zerojudge.tw/ShowProblem?problemid=a828
觀察規律
首位數每9個+1
找出長度、首位數、第二位數就可以拼出答案

作張表可以防超時
```cpp=
#include<bits/stdc++.h>
using namespace std;
const int N = 100000005;
int chart_nums[81][2];
void chart(){
    int cnt = 0;
    for(int i = 1;i <= 9;i ++){
        for(int j = 0;j <= 9;j ++){
            if (i != j){
                chart_nums[cnt][0] = i;
                chart_nums[cnt][1] = j;
                cnt ++;
            }
        }
    }
}
int main(){
    int n;
    chart();
    while(cin >> n){
        int len = (n-1) / 81 + 3;
        int rest = (n-1) % 81;
        for(int i = 0;i <= (len-2);i += 2){
            cout << chart_nums[rest][0] << chart_nums[rest][1];
        }
        if (len % 2 == 1) cout << chart_nums[rest][0];
        cout << endl;
    }
}

```
> 回到主頁: https://hackmd.io/C_fY69EtSXeHHPLT1QxUug