4 条题解

  • 1
    @ 2023-5-3 9:17:31

    #include<bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const int K = 12345; int n; int f[N][2]; int main() { cin >> n; if (n == 1) { f[1][0] = 8; f[1][1] = 1; cout << f[1][0] << endl; } else { f[1][0] = 9; f[1][1] = 1; for (int i = 2; i <= n - 1; ++i) { //K = 12345 f[i][0] = ((f[i - 1][1] % K) + (9 * (f[i-1][0] % K)) % K) % K; f[i][1] = ((f[i - 1][0] % K) + (9 * (f[i-1][1] % K)) % K) % K; } f[n][0] = ((f[n - 1][1] % K) + (8 * (f[n-1][0] % K)) % K) % K; cout << f[n][0] << endl; }

    return 0;
    

    }

    • 0
      @ 2023-10-21 16:13:30

      #include<bits/stdc++.h> using namespace std; int jis[1001]; int ous[1001]; int main(){ int n; cin>>n; jis[1]=1; ous[1]=8; for(int i=2;i<=n;i++){ jis[i]=(jis[i-1]*9+ous[i-1])%12345; ous[i]=(ous[i-1]*9+jis[i-1])%12345; } cout<<ous[n]; return 0; }

      • 0
        @ 2023-8-23 9:40:08
        #include<bits/stdc++.h>
        using namespace std;
        const int N = 1e3 + 10;
        const int K = 12345;
        int n;
        int f[N][2];  
        int main() {
            ios::sync_with_stdio(false);  
            cin.tie(0);
            cin >> n;
            if (n == 1) {
                f[1][0] = 8;  
                f[1][1] = 1; 
                cout << f[1][0] << endl;
            } else {
                f[1][0] = 9;  
                f[1][1] = 1;
                for (int i = 2; i <= n - 1; ++i) {
                    f[i][0] = ((f[i - 1][1] % K) + (9 * (f[i-1][0] % K)) % K) % K;
                    f[i][1] = ((f[i - 1][0] % K) + (9 * (f[i-1][1] % K)) % K) % K;
                }
                f[n][0] = ((f[n - 1][1] % K) + (8 * (f[n-1][0] % K)) % K) % K;
                cout << f[n][0] << endl;
            }
            return 0;
        }
        // 
        //     	   __  __          __  
        //  	  / / / /_  ______/ /________ 
        //       / /_/ / / / / __  / ___/ __ \
        //  	/ __  / /_/ / /_/ / /  / /_/ /
        //     /_/ /_/\__, /\__,_/_/   \____/ 
        //           /____/                   
        //
        
        • @ 2023-10-23 22:13:04

          用我的HYDRO是吧

      • 0
        @ 2023-4-18 17:23:54
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
            int n;
            cin>>n;
            int a[100000],b[100000];
            a[1]=8;
            b[1]=1;
            for(int i=2;i<=n;i++)
            {
                a[i]=(a[i-1]*9+b[i-1])%12345;
                b[i]=(b[i-1]*9+a[i-1])%12345;
            }
            cout<<a[n]<<endl;
             return 0;
        }
        
        • 1

        信息

        ID
        362
        时间
        1000ms
        内存
        16MiB
        难度
        7
        标签
        递交数
        226
        已通过
        60
        上传者