3134. 短信激活码

13627999316

python处理大数还是很牛逼的:

T =int(input())
for i in range(T):
    n = input()
    a = [i for i in n]#将字符串的每一位存入数组中
    b = [0 for i in range(5)]
    b[0] = a[0];b[1]=a[2];b[2]=a[4];b[3]=a[3];b[4]=a[1]
    b = int("".join(b))
    b = str(pow(b,5))#计算5次方并转为字符串
    ans = b[-5:]#截取倒a数第5到末尾的字符串
    print("case #{}:".format(i))
    print(ans)
Li Dao

注意开long long 99999平方可能会超max_int

include

using namespace std;
const int Go[5]={0,2,4,3,1};
int T;
string strs;

void alter()
{
string tmp;
for(int i=0;i<5;i++) tmp+=strs[Go[i]];
strs=tmp;
return;
}
void solve()
{
cin>>strs;
alter();

int xx;
stringstream ss(strs);
ss>>xx;

long long now=xx;
for(int i=1;i<5;i++) now=(now*xx)%100000;

printf(“%05lld\n”,now);
return;
}
int main()
{
scanf(“%d”,&T);
for(int step=0;step<T;step++)
{
printf(“case #%d:\n”,step);
solve();
}
return 0;
}

BillChen2000

把%05d给忘了,搞了半天补0的方法(

aiden
#include <iostream>
#include <string>
using namespace std;


int main()
{
    int t;
    cin >> t;
    for (auto z = 0; z < t; ++z)
    {
        string buff;
        cin >> buff;
        string str;
        str = str + buff[0] + buff[2] + buff[4] + buff[3] + buff[1];
        int n = stoi(str);
        long long ans = 1; //用int竟然会溢出
        for (int i = 1; i <= 5; ++i)
        {
            ans *= n;
            ans %= 100000;
        }
        cout << "case #" << z << ":" << endl;
        if (ans < 10)
            cout << "0000" << ans << endl;
        else if (ans < 100)
            cout << "000" << ans << endl;
        else if (ans < 1000)
            cout << "00" << ans << endl;
        else if (ans < 10000)
            cout << "0" << ans << endl;
        else
            cout << ans << endl;
    }
    return 0;
}
Sun_shine
#include <iostream>
#include <string>

using namespace std;
using ll = long long;
#define mod 100000;

int main() {
    string p{};
    int n{};
    cin >> n;
    for (int i = 0; i < n && cin >> p; i++) {
        ll m{};
        m = m * 10 + p[0] - '0';
        m = m * 10 + p[2] - '0';
        m = m * 10 + p[4] - '0';
        m = m * 10 + p[3] - '0';
        m = m * 10 + p[1] - '0';
        ll p = 1;
        for (int j = 0; j < 5; j++) {
            p = (p * m) % mod;
        }
        cout << "case #" << i << ':' << endl;
        if (p < 10000 && p >= 1000) cout << '0' << p << endl;
        else if (p < 1000 && p >= 100) cout << "00" << p << endl;
        else if (p < 100 && p >= 10) cout << "000" << p << endl;
        else if (p < 10 && p >= 1) cout << "0000" << p << endl;
        else if (p == 0) cout << "00000" << endl;
        else cout << p << endl;
    }
}
你当前正在回复 博客/题目
存在问题!