結果

問題 No.432 占い(Easy)
ユーザー ebicochinealebicochineal
提出日時 2016-10-21 08:39:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,695 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 75,644 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 09:41:23
合計ジャッジ時間 1,775 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,384 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
typedef long long int LLI;
typedef unsigned long long int ULLI;
using namespace std;

string replace5126(string str, string old_s, string new_s) {
    int i;
    if (old_s == "") { return str; }
    while ((i = str.find(old_s)) > -1) { str.replace(i, old_s.size(), new_s); }
    return str;
}

int count5126(string str, string a) {
    int i = 0, cnt = 0;
    if (a == "") { return -1; }
    while ((i = str.find(a, i)) > -1) { ++cnt; i += a.size(); }
    return cnt;
}

vector<string> split5126(string str, string sep){
    int s = 0, p = 0;
    vector<string> v;
    if (sep == "") {
        v.push_back(str);
        return v;
    }
    while ((p = str.find(sep, s)) > -1) {
        v.push_back(str.substr(s, p - s));
        s = p + sep.size();
    }
    v.push_back(str.substr(s, str.size()));
    return v;
}

string slice5126(string str, int a, int b){
    int s = a < 0 ? str.size() + a : a;
    int e = b < 0 ? str.size() + b : b;
    e = b == 0 ? str.size() : e;
    return str.substr(s, (s > e ? s : e) - s);
}

string solva (string s) {
    int a;
    while (s.size() > 1) {
        for (int i = 0; i < s.size() - 1; ++i) {
            a = ((int)s[i] - 48) + ((int)s[i + 1] - 48);
            a = a > 9 ? a % 10 + 1 : a;
            s[i] = (char)(a + 48);
        }
        s = slice5126(s, 0, -1);
    }
    return s;
}

int main() {
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        cout << solva(s) << endl;
    }
    return 0;
}
0