题解:P10414 [蓝桥杯 2023 国 A] 2023 次方

· · 题解

题目传送门

Part 1 题意

Part 1.5 代码

Part 2 高斯降幂

Part 3 降幂\times1

\Large2^{3^{4^{5^{...^{2023}}}}} \equiv \Large2^{3^{4^{5^{...^{2023}}}} \pmod x}
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;
    char s=getchar();
    while(s<'0'||s>'9'){
        if(s=='-') f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9'){
        x=(x<<1)+(x<<3)+(s^48);
        s=getchar();
    }
    return x*f;
}

signed main(){
    int sum=1;
    for(int i=1;i<=2023;i++){
        sum<<=1;
        sum%=2023;
        if(sum==2&&i!=1){
            cout<<i-1<<endl;
            return 0;
        }
    }
    return 0;
}

Part 4 降幂\times2

\Large3^{4^{5^{6^{...^{2023}}}}} \equiv \Large3^{4^{5^{6^{...^{2023}}}}\pmod y}
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;
    char s=getchar();
    while(s<'0'||s>'9'){
        if(s=='-') f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9'){
        x=(x<<1)+(x<<3)+(s^48);
        s=getchar();
    }
    return x*f;
}

signed main(){
    int sum=1;
    for(int i=1;i<=408;i++){
        sum*=3;
        sum%=408;
        if(sum==3&&i!=1){
            cout<<i-1<<endl;
            return 0;
        }
    }
    return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;
    char s=getchar();
    while(s<'0'||s>'9'){
        if(s=='-') f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9'){
        x=(x<<1)+(x<<3)+(s^48);
        s=getchar();
    }
    return x*f;
}

signed main(){
    int sum=1;
    for(int i=1;i<=16;i++){
        sum*=3;
        sum%=408;
    }
    cout<<sum;
    return 0;
}

Part 5 计算答案

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;
    char s=getchar();
    while(s<'0'||s>'9'){
        if(s=='-') f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9'){
        x=(x<<1)+(x<<3)+(s^48);
        s=getchar();
    }
    return x*f;
}

signed main(){
    int sum=1;
    for(int i=1;i<=273;i++){
        sum<<=1;
        sum%=2023;
    }
    cout<<sum;
    return 0;
}

Part 6 结尾

AC 链接