提出 #28640894
ソースコード 拡げる
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sz(x) (int)x.size() //#define sqr(x) x*x //#pragma GCC optimize(3) //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native") //#pragma GCC optimize("unroll-loops") using namespace std; using namespace __gnu_pbds; //#define int long long template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; void solve() { string s; cin >> s; int sum = 0; for (int i = 0; i < s.size(); i++) sum += s[i] - '0'; int carry = 0; string ans; for (int i = s.size() - 1; i >= 0; i--) { int r = (sum + carry) % 10; ans += (r + '0'); carry = (sum + carry) / 10; sum -= (s[i] - '0'); } while (carry > 0) { ans += (carry % 10 + '0'); carry /= 10; } reverse(ans.begin(), ans.end()); cout << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; t = 1; while (t--) { solve(); } return 0; } /* 4 4 1 2 1 3 1 1 1 2 1 3 1 4 */
提出情報
提出日時 | |
---|---|
問題 | E - Σ[k=0..10^100]floor(X/10^k) |
ユーザ | GrgaExe |
言語 | C++ (GCC 9.2.1) |
得点 | 500 |
コード長 | 1301 Byte |
結果 | AC |
実行時間 | 14 ms |
メモリ | 4672 KiB |
コンパイルエラー
./Main.cpp: In function ‘void solve()’: ./Main.cpp:22:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 22 | for (int i = 0; i < s.size(); i++) | ~~^~~~~~~~~~
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 500 / 500 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
hand_01.txt | AC | 10 ms | 3480 KiB |
hand_02.txt | AC | 9 ms | 4628 KiB |
hand_03.txt | AC | 5 ms | 3584 KiB |
hand_04.txt | AC | 12 ms | 4672 KiB |
sample_01.txt | AC | 4 ms | 3468 KiB |
sample_02.txt | AC | 2 ms | 3524 KiB |
sample_03.txt | AC | 2 ms | 3584 KiB |
test_01.txt | AC | 2 ms | 3580 KiB |
test_02.txt | AC | 8 ms | 4168 KiB |
test_03.txt | AC | 11 ms | 4132 KiB |
test_04.txt | AC | 8 ms | 4196 KiB |
test_05.txt | AC | 11 ms | 4432 KiB |
test_06.txt | AC | 14 ms | 4356 KiB |
test_07.txt | AC | 7 ms | 3864 KiB |
test_08.txt | AC | 7 ms | 3604 KiB |
test_09.txt | AC | 12 ms | 4564 KiB |
test_10.txt | AC | 13 ms | 4672 KiB |
test_11.txt | AC | 10 ms | 4608 KiB |
test_12.txt | AC | 10 ms | 4496 KiB |