← Back to List

11575번: Affine Cipher ↗

Solutions

C++14
322 B | 322 chars
#include <iostream>
#include <string>
using namespace std;
int T,a,b;
string s;
int main()
{
    cin>>T;
    for(int t=0; t<T; t++)
    {
        cin>>a>>b>>s;
        for(auto iter=s.begin(); iter != s.end(); ++iter)
        {
            cout<<(char) ((a*((*iter)-'A')+b)%26 + 'A');
        }
        cout<<endl;
    }
}