60分 3 4点 WA

P1914 小书童——凯撒密码

SparrowHe @ 2019-03-15 22:34:39

如题,使用python3编写

3点报错:

wrong answer On line 1 column 1, read (ASCII -62), expected q. 得分0

4点报错

wrong answer On line 1 column 2, read {, expected a. 得分0

代码:

x = int(input())
y = str(input())
ans=[""]*len(y)
retAns=str()
for i in range(0,len(y)):
    ans[i] = ord(y[i]) + x
    retAns += chr(ans[i])
print(retAns)

by 天才byt @ 2019-03-15 22:37:44

人生苦短


by Clever_Jimmy @ 2019-03-15 22:57:53

我用python


by 浪花似月 @ 2019-03-15 23:04:14

#include<bits/stdc++.h>

using namespace std;
int main()
{
    string s;
    int n,i,j;
    cin>>n;
    cin>>s;
    for(i=0;i<s.size();++i)
    {
        for(j=1;j<=n;++j)
        {
            ++s[i];
            if(s[i]>'z')
            s[i]='a';
        }
    }
    cout<<s;
    return 0;
}

by SparrowHe @ 2019-03-15 23:15:51

不要偏题哇好不好


by Alex_Cui @ 2019-03-15 23:21:39

def main():
    n = int(input())
    s = input()
    for c in s:
        print(chr((ord(c) - 97 + n) % 26 + 97), end='')
    return 0

if __name__ == "__main__":
    main()

by Alex_Cui @ 2019-03-15 23:30:55

print(''.join([[chr((ord(c) - 97 + n) % 26 + 97) for c in s] for n, s in [(int(input()), input())]][0]))

手动滑稽


by openjudgenoi @ 2019-03-25 21:04:09

直接+-ASCII码会超上限


|