题解:P9930 [NFLSPC #6] 1064 病毒

· · 题解

核心结论

若迭代次数 y \geq 2,则对任意 i,f_y(i)=213。

一共存在 10^{x} 个数字,答案:

ans = 213 \times 10^{x}

数字规模巨大,无法使用整数存储,采用字符串形式输出。

特判:当 y = 1 时输出 11。

AC 代码

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int x,y;
        cin >> x >> y;
        if(y >= 2){
            cout << "213";
            while(x--){
                cout << '0';
            }
        }else{
            cout << "11";
        }
        cout << endl;
    }
    return 0;
}