Submission #00090
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #include<bits/stdc++.h> using namespace std; using int64 = long long ; //const int mod = 1e9 + 7; const int mod = 998244353; const int64 infll = (1LL << 62) - 1; const int inf = (1 << 30) - 1; struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio( false ); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; template < typename T1, typename T2 > ostream &operator<<(ostream &os, const pair< T1, T2 > &p) { os << p.first << " " << p.second; return os; } template < typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; } template < typename T > ostream &operator<<(ostream &os, const vector< T > &v) { for ( int i = 0; i < ( int ) v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : "" ); } return os; } template < typename T > istream &operator>>(istream &is, vector< T > &v) { for (T &in : v) is >> in; return is; } template < typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true ); } template < typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true ); } template < typename T = int64 > vector< T > make_v( size_t a) { return vector< T >(a); } template < typename T, typename ... Ts > auto make_v( size_t a, Ts... ts) { return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...)); } template < typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; } template < typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } template < typename F > struct FixPoint : F { FixPoint(F &&f) : F(forward< F >(f)) {} template < typename ... Args > decltype(auto) operator()(Args &&... args) const { return F::operator()(* this , forward< Args >(args)...); } }; template < typename F > inline decltype(auto) MFP(F &&f) { return FixPoint< F >{forward< F >(f)}; } /** * @brief Kth-Root * @docs docs/kth-root.md */ uint64_t kth_root(uint64_t a, int k) { if (k == 1) return a; auto check = [&](uint32_t x) { uint64_t mul = 1; for ( int j = 0; j < k; j++) { if (__builtin_mul_overflow(mul, x, &mul)) return false ; } return mul <= a; }; uint64_t ret = 0; for ( int i = 31; i >= 0; i--) { if (check(ret | (1u << i))) ret |= 1u << i; } return ret; } int main() { int64 N; cin >> N; for (int64 i = 1; i * i < N; i++) { int64 rest = N - i * i; int64 j = kth_root(rest, 2); if (i * i + j * j == N) { cout << i << " " << j << "\n" ; return 0; } } } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - さらば2020、ようこそ2021 |
ユーザー名 | ei1333 |
投稿日時 | 2020-12-30 17:03:38 |
言語 | C++17 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 2805 Byte |
最大実行時間 | 43 ms |
最大メモリ使用量 | 844 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 26 ms | 604 KB |
1
|
in02.txt | AC | 21 ms | 432 KB |
1
|
in03.txt | AC | 32 ms | 392 KB |
1
|
in04.txt | AC | 21 ms | 476 KB |
1
|
in05.txt | AC | 39 ms | 556 KB |
1
|
in06.txt | AC | 24 ms | 508 KB |
1
|
in07.txt | AC | 26 ms | 588 KB |
1
|
in08.txt | AC | 33 ms | 676 KB |
1
|
in09.txt | AC | 18 ms | 632 KB |
1
|
in10.txt | AC | 30 ms | 588 KB |
1
|
in11.txt | AC | 26 ms | 540 KB |
1
|
in12.txt | AC | 28 ms | 496 KB |
1
|
in13.txt | AC | 20 ms | 448 KB |
1
|
in14.txt | AC | 28 ms | 656 KB |
1
|
in15.txt | AC | 25 ms | 612 KB |
1
|
in16.txt | AC | 25 ms | 568 KB |
1
|
in17.txt | AC | 27 ms | 528 KB |
1
|
in18.txt | AC | 25 ms | 616 KB |
1
|
in19.txt | AC | 32 ms | 448 KB |
1
|
in20.txt | AC | 25 ms | 400 KB |
1
|
in21.txt | AC | 26 ms | 608 KB |
1
|
in22.txt | AC | 27 ms | 560 KB |
1
|
in23.txt | AC | 25 ms | 636 KB |
1
|
in24.txt | AC | 38 ms | 592 KB |
1
|
in25.txt | AC | 28 ms | 676 KB |
1
|
in26.txt | AC | 23 ms | 628 KB |
1
|
in27.txt | AC | 27 ms | 588 KB |
1
|
in28.txt | AC | 25 ms | 544 KB |
1
|
in29.txt | AC | 22 ms | 624 KB |
1
|
in30.txt | AC | 22 ms | 712 KB |
1
|
in31.txt | AC | 39 ms | 664 KB |
1
|
in32.txt | AC | 28 ms | 620 KB |
1
|
in33.txt | AC | 30 ms | 576 KB |
1
|
in34.txt | AC | 41 ms | 792 KB |
1
|
in35.txt | AC | 29 ms | 748 KB |
1
|
in36.txt | AC | 25 ms | 704 KB |
1
|
in37.txt | AC | 25 ms | 784 KB |
1
|
in38.txt | AC | 31 ms | 732 KB |
1
|
in39.txt | AC | 26 ms | 688 KB |
1
|
in40.txt | AC | 27 ms | 640 KB |
1
|
in41.txt | AC | 19 ms | 600 KB |
1
|
in42.txt | AC | 18 ms | 684 KB |
1
|
in43.txt | AC | 20 ms | 644 KB |
1
|
in44.txt | AC | 21 ms | 720 KB |
1
|
in45.txt | AC | 31 ms | 676 KB |
1
|
in46.txt | AC | 26 ms | 632 KB |
1
|
in47.txt | AC | 30 ms | 720 KB |
1
|
in48.txt | AC | 27 ms | 552 KB |
1
|
in49.txt | AC | 22 ms | 764 KB |
1
|
in50.txt | AC | 23 ms | 596 KB |
1
|
in51.txt | AC | 36 ms | 684 KB |
1
|
in52.txt | AC | 43 ms | 768 KB |
1
|
in53.txt | AC | 32 ms | 728 KB |
1
|
in54.txt | AC | 25 ms | 812 KB |
1
|
in55.txt | AC | 26 ms | 640 KB |
1
|
in56.txt | AC | 17 ms | 720 KB |
1
|
in57.txt | AC | 28 ms | 800 KB |
1
|
in58.txt | AC | 29 ms | 756 KB |
1
|
in59.txt | AC | 21 ms | 844 KB |
1
|
in60.txt | AC | 28 ms | 804 KB |
1
|
sample01.txt | AC | 15 ms | 760 KB |
1
|
sample02.txt | AC | 20 ms | 716 KB |
1
|