답안 #1066786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066786 2024-08-20T07:06:26 Z 김은성(#11121) Present (RMI21_present) C++17
8 / 100
298 ms 1480 KB
#include <bits/stdc++.h>
using namespace std;
const int K = 20;
vector<int> ans;
int gcd(int a, int b){
	if(b==0)
		return a;
	return gcd(b, a%b);
}
bool good(int mask){
	int i, j;
	for(i=1; i<=K; i++){
		for(j=1; j<=K; j++){
			if((mask & (1<<(i-1))) && (mask & (1<<(j-1))) && !(mask & (1<<(gcd(i, j)-1))))
				return false;
		}
	}
	return true;
}
void printset(int mask){
	vector<int> ans;
	int i;
	for(i=1; i<=K; i++){
		if((mask & (1<<(i-1))))
			ans.push_back(i);
	}
	printf("%d ", ans.size());
	for(int u: ans){
		printf("%d ", u);
	}
	printf("\n");
}
int main(){
	int t, i;
	for(i=0; i<(1<<K); i++){
		if(good(i))
			ans.push_back(i);
	}
	//printf("ans.sz=%d\n", ans.size());
	scanf("%d", &t);
	int k;
	while(t--){
		scanf("%d", &k);
		printset(ans[k]);
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void printset(int)':
Main.cpp:27:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   27 |  printf("%d ", ans.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp: In function 'int main()':
Main.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
Main.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 988 KB Output is correct
2 Correct 288 ms 916 KB Output is correct
3 Correct 298 ms 972 KB Output is correct
4 Correct 291 ms 1052 KB Output is correct
5 Correct 289 ms 856 KB Output is correct
6 Correct 297 ms 996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 988 KB Output is correct
2 Correct 288 ms 916 KB Output is correct
3 Correct 298 ms 972 KB Output is correct
4 Correct 291 ms 1052 KB Output is correct
5 Correct 289 ms 856 KB Output is correct
6 Correct 297 ms 996 KB Output is correct
7 Runtime error 290 ms 1480 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 988 KB Output is correct
2 Correct 288 ms 916 KB Output is correct
3 Correct 298 ms 972 KB Output is correct
4 Correct 291 ms 1052 KB Output is correct
5 Correct 289 ms 856 KB Output is correct
6 Correct 297 ms 996 KB Output is correct
7 Runtime error 290 ms 1480 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 988 KB Output is correct
2 Correct 288 ms 916 KB Output is correct
3 Correct 298 ms 972 KB Output is correct
4 Correct 291 ms 1052 KB Output is correct
5 Correct 289 ms 856 KB Output is correct
6 Correct 297 ms 996 KB Output is correct
7 Runtime error 290 ms 1480 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 988 KB Output is correct
2 Correct 288 ms 916 KB Output is correct
3 Correct 298 ms 972 KB Output is correct
4 Correct 291 ms 1052 KB Output is correct
5 Correct 289 ms 856 KB Output is correct
6 Correct 297 ms 996 KB Output is correct
7 Runtime error 290 ms 1480 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -