提出 #68790074


ソースコード 拡げる

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

using namespace std;

// Write implementation prototypes Here
void solve(){
    // PRINT THE ANSWER!
    ll lb = -1e8, ub = 1e8;
    ll x; cin >> x;
    set<ll> ans;
    for (ll k = lb; k <= ub; ++k){
        if ((x - k*k) % (2*k-1LL) == 0){
            ans.insert((x-k*k)/(2*k-1LL));
        }
    }
    cout << ans.size() << endl;
    for (auto it: ans) cout << it << " ";
    cout << endl;
}
// Driver code
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen("test.inp", "r") != NULL) {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
        freopen("test.err", "w", stderr);
    }

    ll test_cases = 1;
    // cin >> test_cases;
    for(int i = 0; i < test_cases; ++i){
        solve();
    }
    return 0;
}

提出情報

提出日時
問題 G - sqrt(n²+n+X)
ユーザ jonteo2001
言語 C++ 20 (gcc 12.2)
得点 575
コード長 965 Byte
結果 AC
実行時間 577 ms
メモリ 3768 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:29:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:31:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         freopen("test.err", "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 575 / 575
結果
AC × 3
AC × 63
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt, 01_handmade_32.txt, 01_handmade_33.txt, 01_handmade_34.txt, 01_handmade_35.txt, 01_handmade_36.txt, 01_handmade_37.txt, 01_handmade_38.txt, 01_handmade_39.txt, 01_handmade_40.txt, 01_handmade_41.txt, 01_handmade_42.txt, 01_handmade_43.txt, 01_handmade_44.txt, 01_handmade_45.txt, 01_handmade_46.txt, 01_handmade_47.txt, 01_handmade_48.txt, 01_handmade_49.txt, 02_radom_00.txt, 02_radom_01.txt, 02_radom_02.txt, 02_radom_03.txt, 02_radom_04.txt, 02_radom_05.txt, 02_radom_06.txt, 02_radom_07.txt, 02_radom_08.txt, 02_radom_09.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 575 ms 3364 KiB
00_sample_01.txt AC 575 ms 3432 KiB
00_sample_02.txt AC 575 ms 3544 KiB
01_handmade_00.txt AC 575 ms 3524 KiB
01_handmade_01.txt AC 576 ms 3508 KiB
01_handmade_02.txt AC 575 ms 3624 KiB
01_handmade_03.txt AC 576 ms 3508 KiB
01_handmade_04.txt AC 576 ms 3428 KiB
01_handmade_05.txt AC 575 ms 3428 KiB
01_handmade_06.txt AC 575 ms 3480 KiB
01_handmade_07.txt AC 575 ms 3428 KiB
01_handmade_08.txt AC 576 ms 3432 KiB
01_handmade_09.txt AC 575 ms 3424 KiB
01_handmade_10.txt AC 576 ms 3508 KiB
01_handmade_11.txt AC 575 ms 3484 KiB
01_handmade_12.txt AC 575 ms 3556 KiB
01_handmade_13.txt AC 575 ms 3480 KiB
01_handmade_14.txt AC 575 ms 3520 KiB
01_handmade_15.txt AC 575 ms 3424 KiB
01_handmade_16.txt AC 575 ms 3496 KiB
01_handmade_17.txt AC 576 ms 3560 KiB
01_handmade_18.txt AC 576 ms 3480 KiB
01_handmade_19.txt AC 575 ms 3492 KiB
01_handmade_20.txt AC 576 ms 3512 KiB
01_handmade_21.txt AC 575 ms 3560 KiB
01_handmade_22.txt AC 576 ms 3428 KiB
01_handmade_23.txt AC 576 ms 3496 KiB
01_handmade_24.txt AC 575 ms 3424 KiB
01_handmade_25.txt AC 576 ms 3480 KiB
01_handmade_26.txt AC 576 ms 3444 KiB
01_handmade_27.txt AC 575 ms 3508 KiB
01_handmade_28.txt AC 575 ms 3508 KiB
01_handmade_29.txt AC 575 ms 3492 KiB
01_handmade_30.txt AC 576 ms 3624 KiB
01_handmade_31.txt AC 575 ms 3500 KiB
01_handmade_32.txt AC 576 ms 3512 KiB
01_handmade_33.txt AC 575 ms 3508 KiB
01_handmade_34.txt AC 576 ms 3512 KiB
01_handmade_35.txt AC 576 ms 3516 KiB
01_handmade_36.txt AC 576 ms 3500 KiB
01_handmade_37.txt AC 576 ms 3512 KiB
01_handmade_38.txt AC 576 ms 3368 KiB
01_handmade_39.txt AC 576 ms 3452 KiB
01_handmade_40.txt AC 575 ms 3364 KiB
01_handmade_41.txt AC 575 ms 3516 KiB
01_handmade_42.txt AC 575 ms 3504 KiB
01_handmade_43.txt AC 575 ms 3432 KiB
01_handmade_44.txt AC 576 ms 3428 KiB
01_handmade_45.txt AC 575 ms 3488 KiB
01_handmade_46.txt AC 576 ms 3396 KiB
01_handmade_47.txt AC 575 ms 3440 KiB
01_handmade_48.txt AC 575 ms 3560 KiB
01_handmade_49.txt AC 577 ms 3768 KiB
02_radom_00.txt AC 575 ms 3508 KiB
02_radom_01.txt AC 575 ms 3428 KiB
02_radom_02.txt AC 575 ms 3428 KiB
02_radom_03.txt AC 576 ms 3444 KiB
02_radom_04.txt AC 576 ms 3368 KiB
02_radom_05.txt AC 575 ms 3428 KiB
02_radom_06.txt AC 575 ms 3508 KiB
02_radom_07.txt AC 575 ms 3432 KiB
02_radom_08.txt AC 575 ms 3488 KiB
02_radom_09.txt AC 576 ms 3572 KiB