답안 #1066802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066802 2024-08-20T07:24:26 Z 김은성(#11121) Present (RMI21_present) C++17
8 / 100
1694 ms 448 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int K = 40;
const int gap = 210000;
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, 2449887, 5183227, 8296815, 12925815, 17563519, };
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 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1694 ms 428 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1694 ms 428 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1694 ms 428 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1694 ms 428 KB Output isn't correct
8 Halted 0 ms 0 KB -