为什么全部超时了???

P1914 小书童——凯撒密码

LabmemNo_012LzTopic @ 2024-06-11 19:26:34

#include<stdio.h>

int main()
{
    int n,x;
    char c;
    scanf("%d", &n);
    getchar();
    while ((c = getchar()) != '\n')
    {
        x = (c + n) % 122;
        if (x > 97 && x < 122)c += n;
        else
        {
            c = 'a' + x - 1;
            if (x == 0)c = 'z';
        }
        printf("%c", c);
    }
    return 0;
}

by renzhanwen @ 2024-06-11 19:31:27

@LabmemNo_012LzTopic


#include<bits/stdc++.h>
using namespace std;
int main() 
{
    char a[100];
    for(int i=0;i<=25;i++)
        a[i]=i+96+1;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k=s.size();
    for(int i=0;i<k;i++)
    {
        int x=int(s[i])-97;
        cout<<a[(n+x)%26];
    } 
    return 0;
}

by Autumn_Rain @ 2024-06-11 20:07:04

和那个0分求助的是情头(?)

坏了成joker了


|