結果
問題 | No.1595 The Final Digit |
ユーザー | miscalc |
提出日時 | 2021-07-09 22:04:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,385 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 181,360 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 16:27:42 |
合計ジャッジ時間 | 2,455 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:45:27: warning: 'R' may be used uninitialized [-Wmaybe-uninitialized] 45 | ll x = (K - 3 - L) % (R - L); | ~~~^~~~ main.cpp:28:9: note: 'R' was declared here 28 | ll L, R; | ^ main.cpp:46:28: warning: 'L' may be used uninitialized [-Wmaybe-uninitialized] 46 | ll ans = get<2>(his.at(L + x)); | ~~^~~ main.cpp:28:6: note: 'L' was declared here 28 | ll L, R; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using tlll = tuple<ll, ll, ll>; constexpr ll MOD = 1e9 + 7; //constexpr ll MOD = 998244353; //constexpr ll MOD = ; ll mod(ll A, ll M) {return (A % M + M) % M;} constexpr ll INF = 1LL << 60; template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} ll divceil(ll A, ll B) {return (A + (B - 1)) / B;} #define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false) int main() { ll p, q, r, K; cin >> p >> q >> r >> K; p %= 10, q %= 10, r %= 10; tlll pqr = make_tuple(p, q, r); map<tlll, ll> mp; mp[pqr] = 0; vector<tlll> his; his.push_back(pqr); ll L, R; for (ll k = 1; k < 1333; k++) { ll s = (p + q + r) % 10; p = q, q = r, r = s; tlll pqr = make_tuple(p, q, r); if (mp.count(pqr) == 0) mp[pqr] = k; else { L = mp[pqr], R = k; break; } his.push_back(pqr); } ll x = (K - 3 - L) % (R - L); ll ans = get<2>(his.at(L + x)); cout << ans << endl; /* ll i = 0; for (auto pqr : his) { ll p = get<0>(pqr), q = get<1>(pqr), r = get<2>(pqr); cerr << i << " " << p << " " << q << " " << r << endl; i++; } cerr << L << " " << R << endl; //*/ }