CSES - Practice Contest 2024 - Results
Submission details
Task:Interesting number
Sender:\(._.)/
Submission time:2024-09-28 16:39:26 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1--details
#2--details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < nums.size(); i++)
      |                     ~~^~~~~~~~~~~~~
input/code.cpp:55:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for (int idx = 0; idx < correctNums.size() && !found; idx++)
      |                               ~~~~^~~~~~~~~~~~~~~~~~~~

Code

// Online C++ compiler to run C++ program online
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
    vector<int> nums = {
        1, 2, 3, 4, 5, 6, 7, 8, 9,
        11, 22, 33, 44, 55, 66, 77, 88, 99,
        101, 111, 121, 131, 141, 151, 161, 171, 181, 191,
        202, 212, 222, 232, 242, 252, 262, 272, 282, 292,
        303, 313, 323, 333, 343, 353, 363, 373, 383, 393,
        404, 414, 424, 434, 444, 454, 464, 474, 484, 494,
        505, 515, 525, 535, 545, 555, 565, 575, 585, 595,
        606, 616, 626, 636, 646, 656, 666, 676, 686, 696,
        707, 717, 727, 737, 747, 757, 767, 777, 787, 797,
        808, 818, 828, 838, 848, 858, 868, 878, 888, 898,
        909, 919, 929, 939, 949, 959, 969, 979, 989, 999
    };
    vector<int> correctNums = {};
    
    for (int i = 0; i < nums.size(); i++)
    {
        int k = 2;
        bool addNum = true;
        while (k * k < nums[i])
        {
            if (nums[i] % k == 0)
            {
                addNum = false;
                break;
            }
            k += 1;
        }
        if (addNum)
            correctNums.push_back(nums[i]);
    }
    
    //for (int i = 0; i < correctNums.size(); i++)
    //    cout << correctNums[i] << " ";
    
    int t;
    cin >> t;
    for (int test = 0; test < t; t++)
    {
        int n;
        cin >> n;
        bool found = false;
        for (int i = 0; i < n; i++)
        {
            int interesting;
            cin >> interesting;
            for (int idx = 0; idx < correctNums.size() && !found; idx++)
                if (correctNums[idx] == interesting)
                {
                    cout << interesting << endl;
                    found = true;
                    break;
                }
        }
    }

    return 0;
}

Test details

Test 1

Verdict:

input
1000
9
300 988 956 931 116 3 386 202 ...

correct output
3
3
181
919
191
...

user output
(empty)

Test 2

Verdict:

input
1
100000
72 247 605 249 10 422 594 490 ...

correct output
191

user output
(empty)