提出 #72173547


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double
#define ull unsigned long long
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define s second
#define f first
#define pb push_back
#define oo 1000000000000000000ll
#define all(a) (a).begin(), a.end()
#define rall(a) (a).rbegin(), a.rend()
#define mp make_pair

void solve() {

    int n; cin >> n;
    vector<int> cnt(n+1);

    for (int i = 1; i * i <= n; ++i){
        for (int j = i+1; i * i + j * j <= n; ++j){
            cnt[i * i + j * j]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i)
        if (cnt[i] == 1) ans++;

    cout << ans << "\n";
    for (int i = 1; i <= n; ++i){
        if (cnt[i] == 1) cout << i << " ";
    }

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tst; tst = 1;
    //cin >> tst;
    while (tst--){
        solve();
    }

    return 0;

}

提出情報

提出日時
問題 C - 2026
ユーザ snasibov05
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1068 Byte
結果 AC
実行時間 119 ms
メモリ 85560 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 18
セット名 テストケース
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_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3588 KiB
00_sample_01.txt AC 1 ms 3608 KiB
00_sample_02.txt AC 1 ms 3612 KiB
01_random_00.txt AC 48 ms 36424 KiB
01_random_01.txt AC 106 ms 75748 KiB
01_random_02.txt AC 47 ms 35840 KiB
01_random_03.txt AC 113 ms 79472 KiB
01_random_04.txt AC 29 ms 23404 KiB
01_random_05.txt AC 55 ms 42828 KiB
01_random_06.txt AC 37 ms 29448 KiB
01_random_07.txt AC 33 ms 26756 KiB
01_random_08.txt AC 52 ms 41060 KiB
01_random_09.txt AC 113 ms 82960 KiB
02_corner_00.txt AC 2 ms 3620 KiB
02_corner_01.txt AC 117 ms 85504 KiB
02_corner_02.txt AC 119 ms 85500 KiB
02_corner_03.txt AC 119 ms 85504 KiB
02_corner_04.txt AC 118 ms 85560 KiB