#include<cstdio> #include<algorithm> using namespace std; typedef unsigned long long int lld; lld t[105]; lld N; int k; lld wyn=0; void licz(int i=0, lld w=1){ if(i>=k) return; licz(i+1,w); if(w*t[i] > N) return; w*=t[i]; wyn=max(wyn,w); licz(i,w); return; } int main(void){ scanf("%d %llu\n",&k,&N); for(int i=0;i<k;i++) scanf("%llu",&t[i]); licz(); printf("%llu\n",wyn); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include<cstdio> #include<algorithm> using namespace std; typedef unsigned long long int lld; lld t[105]; lld N; int k; lld wyn=0; void licz(int i=0, lld w=1){ if(i>=k) return; licz(i+1,w); if(w*t[i] > N) return; w*=t[i]; wyn=max(wyn,w); licz(i,w); return; } int main(void){ scanf("%d %llu\n",&k,&N); for(int i=0;i<k;i++) scanf("%llu",&t[i]); licz(); printf("%llu\n",wyn); return 0; } |