提出 #68785856


ソースコード 拡げる

// B87678

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
#include <set>
#include <bitset>
#include <queue>
#include <cstring>
#include <fstream>
#include <cmath>
#include <climits>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define MAX 1000000000
using namespace std;
#define ll long long
#define pii pair<int, int>
#define all(v) ((v).begin()), ((v).end())
#define sz(v) (int)((v).size())
#define inc(i, n) for (int i = 0; i < n; ++i)
#define dec(i, n) for (int i = n; i >= 0; --i)
#define pb emplace_back
const int mod = 998244353;
const int modi = 1000000007;
const int inv2 = 499122177;
const int N = 200000;

vector<vector<ll> > out;

// vector<vector<int> > factors;
// vector<int> dx, dy;

// bool toggle;

// bool check(int i, int j, int &h, int &w, vector<string> &maze){
//     if(i<h&&j<w&&i>=0&&j>=0){
//         if(toggle){
//             if(maze[i][j] == 'x' || maze[i][j] == '.' || maze[i][j] == 'S' || maze[i][j] == 'G' || maze[i][j] == '?') return true; 
//         }else{
//             if(maze[i][j] == 'o' || maze[i][j] == '.' || maze[i][j] == 'S' || maze[i][j] == 'G' || maze[i][j] == '?') return true; 
//         }
//     }
//     return false;
// }

// void build(void){


// }


// int rec()

void solve()    // ifstream &infile
{   
    ll x; cin >> x;
    // 4X-1
    bool neg = false;
    x *= 4;
    if(x < 0){
        x = -x;
        x++;
        neg = true;
    }else{
        x--;
    }

    // cout << "x is " << x << "\n";

    vector<ll> ans;
    if(!neg){
        for(int i = 1; i <=2*1e7+1; i+=2){
            if(x%i == 0){
                if(x/i >= i){
                    ll m1 = (x/i - i)/2;
                    ll m2 = -m1;
                    m1--; m2--;
                    m1 /= 2; m2 /= 2;
                    ans.pb(m1); ans.pb(m2);
                } 
            }
        }
    }else{
        for(int i = 1; i <=2*1e7+1; i+=2){
            if(x%i == 0){
                if(x/i >= i){
                    ll m1 = (x/i + i)/2;
                    ll m2 = -m1;
                    m1--; m2--;
                    m1 /= 2; m2 /= 2;
                    ans.pb(m1); ans.pb(m2);
                } 
            }
        }
    }
    sort(all(ans));
    cout << sz(ans) << "\n";
    out.pb(ans);
    return;
}

signed main()
{
    // ifstream infile("aoc_in.txt"); // Open the input file
    // if (!infile) {
    //     cerr << "Error: Unable to open input file!" << "\n";
    //     return 1; // Exit with an error code if the file can't be opened
    // }
    // dx = {1, 0, -1, 0};
    // dy = {0, 1, 0, -1};

    // factors.resize(10000001);
    int t;
    t = 1;
    // cin >> t;
    while (t--){
        solve();
    }

    for (auto &x : out) {
        // cout << fixed << setprecision(10) << x << "\n";
        for(auto &y : x) cout << y << " ";
        // cout << "\n";
        // cout << x << " ";
    }
    // infile.close();
    return 0;
}





/*

Precision:

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double p = 5, q = 7;
double prob = p / q;
cout << fixed << setprecision(6) << prob << endl;
return 0;
}

Inverse:

const long long MOD = 1e9 + 7 ;
long long modpow( long long a , long long b) {
long long r e s = 1 ;
a %= MOD;
while (b > 0) {
i f (b & 1) r e s = ( r e s ∗ a ) % MOD;
a = ( a ∗ a ) % MOD;
b >>= 1 ;
}
return r e s ;
}
long long modinv ( long long q ) {
return modpow(q , MOD− 2 ) ;
}
// long long ans = (p ∗ modinv ( q ) ) % MOD;

*/

提出情報

提出日時
問題 G - sqrt(n²+n+X)
ユーザ lazyguy1618
言語 C++ 20 (gcc 12.2)
得点 0
コード長 3755 Byte
結果 WA
実行時間 30 ms
メモリ 3652 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 575
結果
AC × 3
AC × 62
WA × 1
セット名 テストケース
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 30 ms 3496 KiB
00_sample_01.txt AC 30 ms 3472 KiB
00_sample_02.txt AC 30 ms 3436 KiB
01_handmade_00.txt AC 30 ms 3472 KiB
01_handmade_01.txt AC 30 ms 3532 KiB
01_handmade_02.txt AC 30 ms 3436 KiB
01_handmade_03.txt AC 30 ms 3648 KiB
01_handmade_04.txt AC 30 ms 3464 KiB
01_handmade_05.txt AC 30 ms 3560 KiB
01_handmade_06.txt AC 30 ms 3460 KiB
01_handmade_07.txt AC 30 ms 3492 KiB
01_handmade_08.txt AC 30 ms 3496 KiB
01_handmade_09.txt AC 30 ms 3424 KiB
01_handmade_10.txt WA 30 ms 3364 KiB
01_handmade_11.txt AC 30 ms 3452 KiB
01_handmade_12.txt AC 30 ms 3464 KiB
01_handmade_13.txt AC 30 ms 3564 KiB
01_handmade_14.txt AC 30 ms 3456 KiB
01_handmade_15.txt AC 30 ms 3488 KiB
01_handmade_16.txt AC 30 ms 3492 KiB
01_handmade_17.txt AC 30 ms 3496 KiB
01_handmade_18.txt AC 30 ms 3428 KiB
01_handmade_19.txt AC 30 ms 3440 KiB
01_handmade_20.txt AC 30 ms 3452 KiB
01_handmade_21.txt AC 30 ms 3464 KiB
01_handmade_22.txt AC 30 ms 3372 KiB
01_handmade_23.txt AC 30 ms 3464 KiB
01_handmade_24.txt AC 30 ms 3492 KiB
01_handmade_25.txt AC 30 ms 3444 KiB
01_handmade_26.txt AC 30 ms 3456 KiB
01_handmade_27.txt AC 30 ms 3448 KiB
01_handmade_28.txt AC 30 ms 3464 KiB
01_handmade_29.txt AC 30 ms 3488 KiB
01_handmade_30.txt AC 30 ms 3652 KiB
01_handmade_31.txt AC 30 ms 3456 KiB
01_handmade_32.txt AC 30 ms 3488 KiB
01_handmade_33.txt AC 30 ms 3648 KiB
01_handmade_34.txt AC 30 ms 3492 KiB
01_handmade_35.txt AC 30 ms 3524 KiB
01_handmade_36.txt AC 30 ms 3652 KiB
01_handmade_37.txt AC 30 ms 3436 KiB
01_handmade_38.txt AC 30 ms 3460 KiB
01_handmade_39.txt AC 30 ms 3436 KiB
01_handmade_40.txt AC 30 ms 3652 KiB
01_handmade_41.txt AC 30 ms 3488 KiB
01_handmade_42.txt AC 30 ms 3480 KiB
01_handmade_43.txt AC 30 ms 3468 KiB
01_handmade_44.txt AC 30 ms 3568 KiB
01_handmade_45.txt AC 30 ms 3472 KiB
01_handmade_46.txt AC 30 ms 3532 KiB
01_handmade_47.txt AC 30 ms 3556 KiB
01_handmade_48.txt AC 30 ms 3564 KiB
01_handmade_49.txt AC 30 ms 3556 KiB
02_radom_00.txt AC 30 ms 3368 KiB
02_radom_01.txt AC 30 ms 3476 KiB
02_radom_02.txt AC 30 ms 3452 KiB
02_radom_03.txt AC 30 ms 3432 KiB
02_radom_04.txt AC 30 ms 3492 KiB
02_radom_05.txt AC 30 ms 3564 KiB
02_radom_06.txt AC 30 ms 3484 KiB
02_radom_07.txt AC 30 ms 3492 KiB
02_radom_08.txt AC 30 ms 3468 KiB
02_radom_09.txt AC 30 ms 3492 KiB