답안 #1066808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066808 2024-08-20T07:28:51 Z 김은성(#11121) Present (RMI21_present) C++17
29 / 100
1291 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int K = 40;
const int gap = 160000;
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++){
		for(j=i+1; j<=K; j++){
			if((mask & (1ll<<(i-1))) && (mask & (1ll<<(j-1))) && !(mask & (1ll<<(gcd(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, 1901295, 4209167, 6168447, 8456703, 12028927, 15752191, 19046523, };
int main(){
	int t;
	int k;
	scanf("%d", &t);
	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:28:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |  printf("%d ", ans.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp: In function 'int main()':
Main.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
Main.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 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 1 ms 600 KB Output is correct
2 Correct 0 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 1271 ms 348 KB Output is correct
8 Correct 902 ms 348 KB Output is correct
9 Correct 1264 ms 592 KB Output is correct
10 Correct 1131 ms 432 KB Output is correct
11 Correct 1291 ms 348 KB Output is correct
12 Correct 1109 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 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 1271 ms 348 KB Output is correct
8 Correct 902 ms 348 KB Output is correct
9 Correct 1264 ms 592 KB Output is correct
10 Correct 1131 ms 432 KB Output is correct
11 Correct 1291 ms 348 KB Output is correct
12 Correct 1109 ms 592 KB Output is correct
13 Incorrect 410 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 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 1271 ms 348 KB Output is correct
8 Correct 902 ms 348 KB Output is correct
9 Correct 1264 ms 592 KB Output is correct
10 Correct 1131 ms 432 KB Output is correct
11 Correct 1291 ms 348 KB Output is correct
12 Correct 1109 ms 592 KB Output is correct
13 Incorrect 410 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 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 1271 ms 348 KB Output is correct
8 Correct 902 ms 348 KB Output is correct
9 Correct 1264 ms 592 KB Output is correct
10 Correct 1131 ms 432 KB Output is correct
11 Correct 1291 ms 348 KB Output is correct
12 Correct 1109 ms 592 KB Output is correct
13 Incorrect 410 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -