답안 #857037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857037 2023-10-05T09:25:42 Z iulia_morariu Present (RMI21_present) C++17
8 / 100
1 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

int cmmdc(int a, int b){
    int c = 0;
    while(b > 0){
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

bool concat_verif(vector<int> &a, int b){
    bool ok = 1;
    for(int i = 0; i < a.size(); i++){
        bool bun = 0;
        for(int j = 0; j <= i; j++){
            if(cmmdc(b, a[i]) == a[j]){
                bun = 1;
                break;
            }
        }

        if(!bun) return 0;
    }
    return 1;
}

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

    //1.
    vector <vector <int>> v(1);
    int t = 0;

    //2.
    cin >> t;

    //3.
    for(int i = 1; i <= 100; i++){
        int s1 = v.size();
        for(int j = 0; j < s1; j++){
            if( concat_verif( v[j], i ) ){
                vector <int> v1 = v[j];
                v1.push_back(i);
                v.push_back( v1 );
            }
            if(v.size() == 100) break;
        }
        if(v.size() == 100) break;
    }

    for(int ii = 0; ii < t; ii++){
        int k; cin >> k;
        cout << v[k].size() << " ";
        for(int i = 0; i < v[k].size(); i++) cout << v[k][i] << " ";
        cout << endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'bool concat_verif(std::vector<int>&, int)':
Main.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i < a.size(); i++){
      |                    ~~^~~~~~~~~~
Main.cpp:16:10: warning: unused variable 'ok' [-Wunused-variable]
   16 |     bool ok = 1;
      |          ^~
Main.cpp: In function 'int main()':
Main.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(int i = 0; i < v[k].size(); i++) cout << v[k][i] << " ";
      |                        ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -