結果

問題 No.432 占い(Easy)
ユーザー zaichu
提出日時 2018-05-14 00:45:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 171,412 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 10:48:57
合計ジャッジ時間 2,655 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
template <typename T> T gcd(T x, T y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
template <typename T> T lcm(T x, T y) {
if (x == 0 || y == 0)
return 0;
return x / gcd(x, y) * y;
}
int ctoi(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return 0;
}
vector<int> p;
vector<int> r;
void init(int n) {
p.reserve(n);
r.resize(n);
for (int i = 0; i < n; i++) {
p[i] = i;
r[i] = 0;
}
}
int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (r[x] < r[y])
p[x] = y;
else {
p[y] = x;
if (r[x] == r[y])
r[x]++;
}
}
int main() {
int T;
cin >> T;
for (int i = 0; i < T; i++) {
string S;
cin >> S;
while (S.size() > 1) {
string tmp = "";
int N = S.size() - 1;
for (int i = 0; i < N; i++) {
int num = ctoi(S[i]) + ctoi(S[i + 1]);
if (num >= 10)
num = num % 10 + num / 10;
tmp += to_string(num);
}
reverse(tmp.begin(), tmp.end());
S = tmp;
}
cout << S << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0