提出 #68745769


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
ll ABS(ll x) { return x<0?-x:x; }
vector<ll> solve(ll x) {
    vector<ll> ans;
    ll mx=0;
    for (ll d=0;d*d<=ABS(x)*2+5;d++) mx=d;
    for (ll d=-mx;d<=mx;d++) {
        // 2 * d * n - n = x - d*d
        ll a=2*d-1,b=x-d*d;
        if (ABS(b)%ABS(a)==0) {
            ll n=b/a;
            ans.push_back(n);
            // printf("%lld %lld\n",n,d);
            // ans.push_back(-n-1);
        }
    }
    // sort(ans.begin(),ans.end());
    return ans;
}
int main() {
    scanf("%lld",&x);
    vector<ll> ans=solve(x);
    sort(ans.begin(),ans.end());
    ans.resize(unique(ans.begin(),ans.end())-ans.begin());
    printf("%d\n",(int)ans.size());
    for (ll &x : ans) printf("%lld ",x); puts("");
    return 0;
}

提出情報

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

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:29:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   29 |     for (ll &x : ans) printf("%lld ",x); puts("");
      |     ^~~
Main.cpp:29:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   29 |     for (ll &x : ans) printf("%lld ",x); puts("");
      |                                          ^~~~
Main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |     scanf("%lld",&x);
      |     ~~~~~^~~~~~~~~~~

ジャッジ結果

セット名 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 1 ms 3572 KiB
00_sample_01.txt AC 1 ms 3708 KiB
00_sample_02.txt AC 1 ms 3896 KiB
01_handmade_00.txt AC 1 ms 3708 KiB
01_handmade_01.txt AC 1 ms 3832 KiB
01_handmade_02.txt AC 1 ms 3656 KiB
01_handmade_03.txt AC 1 ms 3788 KiB
01_handmade_04.txt AC 1 ms 3784 KiB
01_handmade_05.txt AC 1 ms 3652 KiB
01_handmade_06.txt AC 1 ms 3888 KiB
01_handmade_07.txt AC 1 ms 3676 KiB
01_handmade_08.txt AC 1 ms 3680 KiB
01_handmade_09.txt AC 1 ms 3788 KiB
01_handmade_10.txt AC 1 ms 3568 KiB
01_handmade_11.txt AC 1 ms 3784 KiB
01_handmade_12.txt AC 1 ms 3704 KiB
01_handmade_13.txt AC 1 ms 3844 KiB
01_handmade_14.txt AC 1 ms 3700 KiB
01_handmade_15.txt AC 1 ms 3672 KiB
01_handmade_16.txt AC 1 ms 3676 KiB
01_handmade_17.txt AC 1 ms 3656 KiB
01_handmade_18.txt AC 1 ms 3792 KiB
01_handmade_19.txt AC 1 ms 3848 KiB
01_handmade_20.txt AC 1 ms 3776 KiB
01_handmade_21.txt AC 87 ms 3700 KiB
01_handmade_22.txt AC 67 ms 3844 KiB
01_handmade_23.txt AC 71 ms 3680 KiB
01_handmade_24.txt AC 34 ms 3784 KiB
01_handmade_25.txt AC 46 ms 3704 KiB
01_handmade_26.txt AC 71 ms 3680 KiB
01_handmade_27.txt AC 87 ms 3712 KiB
01_handmade_28.txt AC 87 ms 3684 KiB
01_handmade_29.txt AC 87 ms 3892 KiB
01_handmade_30.txt AC 87 ms 3896 KiB
01_handmade_31.txt AC 87 ms 3848 KiB
01_handmade_32.txt AC 87 ms 3784 KiB
01_handmade_33.txt AC 87 ms 3716 KiB
01_handmade_34.txt AC 87 ms 3652 KiB
01_handmade_35.txt AC 87 ms 3784 KiB
01_handmade_36.txt AC 87 ms 3648 KiB
01_handmade_37.txt AC 87 ms 3696 KiB
01_handmade_38.txt AC 88 ms 3848 KiB
01_handmade_39.txt AC 87 ms 3656 KiB
01_handmade_40.txt AC 87 ms 3680 KiB
01_handmade_41.txt AC 87 ms 3840 KiB
01_handmade_42.txt AC 87 ms 3680 KiB
01_handmade_43.txt AC 87 ms 3780 KiB
01_handmade_44.txt AC 87 ms 3624 KiB
01_handmade_45.txt AC 87 ms 3652 KiB
01_handmade_46.txt AC 87 ms 3680 KiB
01_handmade_47.txt AC 87 ms 3780 KiB
01_handmade_48.txt AC 87 ms 3684 KiB
01_handmade_49.txt AC 75 ms 3808 KiB
02_radom_00.txt AC 75 ms 3784 KiB
02_radom_01.txt AC 65 ms 3848 KiB
02_radom_02.txt AC 34 ms 3784 KiB
02_radom_03.txt AC 84 ms 3780 KiB
02_radom_04.txt AC 82 ms 3788 KiB
02_radom_05.txt AC 63 ms 3680 KiB
02_radom_06.txt AC 56 ms 3712 KiB
02_radom_07.txt AC 45 ms 3704 KiB
02_radom_08.txt AC 65 ms 3896 KiB
02_radom_09.txt AC 76 ms 3844 KiB