1 solutions

  • 0
    @ 2022-2-9 10:53:47

    不是多组输入(超时两次)

    #include <bits/stdc++.h>
    using namespace std;
    int s[1507];
    int min(int a,int b,int c){
    	if(a<b) return a<c?a:c;
    	return b<c?b:c;
    }
    void initialization(){
    	s[1]=1;
    	int f2=2,f3=3,f5=5,i=2,i2=2,i3=2,i5=2;
    	while(i<1600){
    		s[i]=min(f2,f3,f5);
    		if(s[i]==f2) f2=s[i2++]*2;
    		if(s[i]==f3) f3=s[i3++]*3;
    		if(s[i]==f5) f5=s[i5++]*5;
    		i++;
    	}
    }
    
    int main(){
    	initialization();
    	int n,x;
    	scanf("%d",&n);
    	while(n--){
    		scanf("%d",&x);
    		printf("%d\n",s[x]);
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    1539
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    # Submissions
    13
    Accepted
    5
    Uploaded By