Submission #72268104


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vii vector<pair<int, int>>
#define vllvector vector<pair<ll, ll>>
#define vb vector<bool>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define rep(i, c, n) for (int i = c; i < n; i++)
const long long llINF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
//! int型でinfを使うならINT_MAX使う
//! int = 2^31 -1

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vi c(n + 1);
    for(int x = 1; x * x <= n; x++) {
        for(int y = x +1; x * x + y * y <= n; y++) {
            c[x * x + y * y]++;
        }
    }
    vi ans;
    rep(i, 1, n+1) {
        if (c[i] == 1) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, 0, ans.size()) {
        cout << ans[i] << (i +1 == ans.size() ? "\n": " ");
    }

}

Submission Info

Submission Time
Task C - 2026
User kar1neko
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1314 Byte
Status AC
Exec Time 92 ms
Memory 50024 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:21:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | #define rep(i, c, n) for (int i = c; i < n; i++)
      |                                        ^
./Main.cpp:45:5: note: in expansion of macro 'rep'
   45 |     rep(i, 0, ans.size()) {
      |     ^~~
./Main.cpp:46:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         cout << ans[i] << (i +1 == ans.size() ? "\n": " ");
      |                            ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 18
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3556 KiB
00_sample_01.txt AC 1 ms 3640 KiB
00_sample_02.txt AC 1 ms 3596 KiB
01_random_00.txt AC 38 ms 22004 KiB
01_random_01.txt AC 80 ms 44356 KiB
01_random_02.txt AC 37 ms 21572 KiB
01_random_03.txt AC 83 ms 46392 KiB
01_random_04.txt AC 23 ms 14540 KiB
01_random_05.txt AC 44 ms 25324 KiB
01_random_06.txt AC 29 ms 18584 KiB
01_random_07.txt AC 27 ms 17356 KiB
01_random_08.txt AC 41 ms 24144 KiB
01_random_09.txt AC 87 ms 48400 KiB
02_corner_00.txt AC 2 ms 3548 KiB
02_corner_01.txt AC 92 ms 50024 KiB
02_corner_02.txt AC 92 ms 49800 KiB
02_corner_03.txt AC 91 ms 49992 KiB
02_corner_04.txt AC 92 ms 49908 KiB