QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630475 | #9307. Clock Master | Saton | RE | 0ms | 0kb | C++20 | 1.6kb | 2024-10-11 18:45:15 | 2024-10-11 18:45:16 |
answer
///by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define int long long
#define ll __int128
#define DD double double
#define LD long double
#define rep(i,a,b) for(int i = (a);i <= (b);i ++)
#define lep(i,a,b) for(int i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
typedef pair<int,int> PII;
const int N = 5e5 + 10,mod = 998244353;
int n,m,k;
const int M = 3e3 + 10;
int primses[M],cnt;
int cntl[M],val[M][20];
bool st[M];
void gar() {
for(int i = 2;i <= M;i ++) {
if(!st[i]) primses[cnt ++] = i;
for(int j = 0;primses[j]*i <= M;j ++) {
st[primses[j]*i] = true;
if(i%primses[j]==0) break;
}
}
for(int i = 0;i < cnt;i ++) {
int len = 1;
int tempv = primses[i];
while(tempv <= M) {
val[i][len ++] = tempv;
tempv *= primses[i];
}
cntl[i] = len - 1;
}
}
double f[M];
void init() {
fill(f,f+M,1);
for(int i = 0;i < cnt;i ++) {
for(int j = M-1;j >= 1;j --) {
for(int k = 1;k <= cntl[i];k ++) {
f[j] = max(f[j],f[j-val[i][k]]*(double)val[i][k]);
}
}
}
}
void solve() {
cin >> n;
printf("%.9lf\n",log(f[n]));
}
signed main() {
gar();
init();
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T;
cin >> T;
while(T --) {
solve();
}
// solve();
return 0;
}
/* /\_/\
* (= ._.)
* / > \>
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 2 7 10