結果

問題 No.1455 拡張ROTN
ユーザー chacoder1
提出日時 2021-07-28 22:34:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 196,012 KB
最終ジャッジ日時 2025-01-23 09:53:55
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
  string s;
  cin>>s;
  ll n;
  cin>>n;  
  while (n > 0) {
    string next_s;
    bool found = false;
    //数字がなくなるまで愚直にやり
    //数字がなくなった時点でn%26周期で出力する
    for (auto c : s) {
      if ('a' <= c && c <= 'z')
        next_s.push_back((c - 'a' + 1) % 26 + 'a');
      else if ('A' <= c && c <= 'Z')
        next_s.push_back((c - 'A' + 1) % 26 + 'A');
      else if ('0' <= c && c <= '8') {
        found = true;
        next_s.push_back(c + 1);
        } else {
        found = true;
        next_s += "CpCzNkSuTbEoA";
        }
      }
    --n; 
    s = next_s;
    if (!found)      
      break;
  }
  for (auto c : s) {
    char ans;
    if ('a' <= c && c <= 'z')
        ans = (c - 'a' + n % 26) % 26 + 'a';
    else if ('A' <= c && c <= 'Z')
        ans = (c - 'A' + n % 26) % 26 + 'A';
    else
        ans = c;
    cout << char(ans);
  }
  cout << endl;
  return 0;
}
0