답안 #1066833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066833 2024-08-20T07:51:40 Z 김은성(#11121) Present (RMI21_present) C++17
29 / 100
1112 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int K = 40;
const int gap = 250000;
int g[45][45];
int gcd(int a, int b){
	if(b==0)
		return a;
	return gcd(b, a%b);
}
bool good(ll mask){
	int i, j;
	for(i=2; i<=K; i++){
		if(!((mask & (1ll<<(i-1)))))
			continue;
		for(j=i+1; j<=K; j++){
			if((mask & (1ll<<(j-1))) && !(mask & (1ll<<(g[i][j]-1))))
				return false;
		}
	}
	return true;
}
void printset(ll  mask){
	vector<int> ans;
	int i;
	for(i=1; i<=K; i++){
		if((mask & (1ll<<(i-1))))
			ans.push_back(i);
	}
	printf("%d ", ans.size());
	for(int u: ans){
		printf("%d ", u);
	}
	printf("\n");
}
ll crit[150235] = {0, 2929323, 6415551, 10806271, 16875563, };
int main(){
	int t;
	int k;
	scanf("%d", &t);
	int i, j;
	for(i=1; i<=K; i++){
		for(j=1; j<=K; j++)
			g[i][j] = gcd(i, j);
	}
	while(t--){
		scanf("%d", &k);
		int cur = k/gap*gap - 1;
		ll i;
		for(i = crit[k/gap]; ; i++){
			if(good(i)){
				cur++;
				if(cur == k)
					break;
			}
		}
		printset(i);
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void printset(ll)':
Main.cpp:31:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   31 |  printf("%d ", ans.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp: In function 'int main()':
Main.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
Main.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
7 Correct 901 ms 440 KB Output is correct
8 Correct 763 ms 436 KB Output is correct
9 Correct 995 ms 344 KB Output is correct
10 Correct 1077 ms 460 KB Output is correct
11 Correct 522 ms 436 KB Output is correct
12 Correct 1112 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
7 Correct 901 ms 440 KB Output is correct
8 Correct 763 ms 436 KB Output is correct
9 Correct 995 ms 344 KB Output is correct
10 Correct 1077 ms 460 KB Output is correct
11 Correct 522 ms 436 KB Output is correct
12 Correct 1112 ms 436 KB Output is correct
13 Incorrect 445 ms 596 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
7 Correct 901 ms 440 KB Output is correct
8 Correct 763 ms 436 KB Output is correct
9 Correct 995 ms 344 KB Output is correct
10 Correct 1077 ms 460 KB Output is correct
11 Correct 522 ms 436 KB Output is correct
12 Correct 1112 ms 436 KB Output is correct
13 Incorrect 445 ms 596 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
7 Correct 901 ms 440 KB Output is correct
8 Correct 763 ms 436 KB Output is correct
9 Correct 995 ms 344 KB Output is correct
10 Correct 1077 ms 460 KB Output is correct
11 Correct 522 ms 436 KB Output is correct
12 Correct 1112 ms 436 KB Output is correct
13 Incorrect 445 ms 596 KB Output isn't correct
14 Halted 0 ms 0 KB -