Submission #1066830

# Submission time Handle Problem Language Result Execution time Memory
1066830 2024-08-20T07:50:04 Z 김은성(#11121) Present (RMI21_present) C++17
0 / 100
434 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int K = 40;
const int gap = 250000;
const ll goal = 1e6 + 6;
vector<int> ans;
int gcd(int a, int b){
	if(b==0)
		return a;
	return gcd(b, a%b);
}
bool good(ll mask, int cur, int lo){
	int i, j;
	for(i=2; i<=cur; i++){
		if(!((mask & (1ll<<(i-1)))))
			continue;
		for(j=max(i+1, lo); j<=cur; j++){
			if((mask & (1ll<<(j-1))) && !(mask & (1ll<<(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");
}
bool ch[1<<18];
int main(){
	int t;
	ll i;
	int now = 0;
	FILE *out = fopen("output.txt", "wt");
	ll cnt = 0;
	ll curm = 0;
	for(i=0; ; i++){
		if(i > (1ll << now)){
			now++;
		}
		if((now <= 18 || ch[curm]) && good(i, now+2, now>18 ? 18 : 0)){
			if(cnt % gap == 0)
				fprintf(out, "%lld, ", i);
			cnt++;
			ch[curm] = 1;
			if(cnt > goal)
				break;
		}
		if(i%1000000 == 0){
			printf("i=%lld cnt=%lld\n", i, cnt);
			fflush(out);
		}
		curm++;
		if(curm == (1<<18))
			curm = 0;
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void printset(int)':
Main.cpp:32:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   32 |  printf("%d ", ans.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp: In function 'int main()':
Main.cpp:40:6: warning: unused variable 't' [-Wunused-variable]
   40 |  int t;
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -