怎么做?
查看原帖
怎么做?
955228
OIer_xhy楼主2024/11/9 20:36

知道是贪心决定最小+质数筛,可是......不会写 code:

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t;
	cin>>t;
	for(int p=1;p<=t;p++){
		int n;
		cin>>n;
		int a[100000]={};
		for(int i=2;i<=n/2;i++){
			if(!a[i]){
				for(int j=i;j<=n;j+=i) a[i]=1;
			}
		}
		i=n;
		while(a[i]) i--;
		n-=a[i];
		for(int i=1;i<=log2(n);i++){
			 a[i]=pow(2,i-1);
		}
		
	} 
    return 0;
}


写到这里就不会了......

2024/11/9 20:36
加载中...