QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140292 | #4613. 避难所 | myee | 100 ✓ | 1ms | 3284kb | C++11 | 3.2kb | 2023-08-15 17:00:38 | 2023-08-15 17:00:40 |
Judging History
answer
// 那就是希望。
// 即便需要取模,也是光明。
#include <algorithm>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
T ans=1%mod;
while(index)
{
if(index&1)ans=ans*base%mod;
base=base*base%mod,index>>=1;
}
return ans;
}
// Heaven and Earth... My guiding star...
// Akira Complex R.I.P.
bol Prime[100005];
std::vector<uint>Ans[126];
int main()
{
#ifdef MYEE
freopen("QAQ.in","r",stdin);
freopen("QAQ.out","w",stdout);
#endif
for(uint i=2;i<=100000;i++)Prime[i]=true;
for(uint i=2;i<=50000;i++)if(Prime[i])for(uint j=i<<1;j<=100000;j+=i)Prime[j]=false;
Ans[9]={6,6,6};
Ans[13]=Ans[14]=Ans[15]={9,10,10};
Ans[17]=Ans[18]={12,14,14};
Ans[19]=Ans[20]=Ans[21]=Ans[22]=Ans[23]=Ans[24]=Ans[25]={10,15,15};
Ans[26]=Ans[27]=Ans[28]={14,20,21};
Ans[29]=Ans[30]={15,21,21};
Ans[31]=Ans[32]={14,21,25};
Ans[33]=Ans[34]=Ans[35]={10,28,28};
Ans[36]=Ans[37]=Ans[38]=Ans[39]=Ans[40]=Ans[41]=Ans[42]=Ans[43]=Ans[44]=Ans[45]=Ans[46]=Ans[47]=Ans[48]=Ans[49]={14,28,28};
Ans[50]=Ans[51]=Ans[52]=Ans[53]=Ans[54]=Ans[55]={15,44,44};
Ans[56]={21,44,44};
Ans[57]=Ans[58]=Ans[59]=Ans[60]={22,44,49};
Ans[61]=Ans[62]=Ans[63]=Ans[64]={21,44,55};
Ans[65]={20,52,52};
Ans[66]={21,44,55};
Ans[67]=Ans[68]=Ans[69]=Ans[70]=Ans[71]=Ans[72]={22,44,49};
Ans[73]=Ans[74]=Ans[75]=Ans[76]=Ans[77]={14,66,66};
Ans[78]=Ans[79]=Ans[80]=Ans[81]=Ans[82]=Ans[83]=Ans[84]=Ans[85]=Ans[86]=Ans[87]=Ans[88]=Ans[89]=Ans[90]=Ans[91]={21,65,65};
Ans[92]=Ans[93]=Ans[94]=Ans[95]=Ans[96]=Ans[97]=Ans[98]=Ans[99]=Ans[100]=Ans[101]=Ans[102]=Ans[103]=Ans[104]=Ans[105]=Ans[106]=Ans[107]=Ans[108]={22,66,77};
Ans[109]=Ans[110]=Ans[111]=Ans[112]=Ans[113]=Ans[114]=Ans[115]=Ans[116]=Ans[117]=Ans[118]=Ans[119]={21,102,102};
Ans[120]=Ans[121]={22,66,77};
Ans[122]=Ans[123]=Ans[124]=Ans[125]={22,91,91};
uint t;scanf("%u",&t);
while(t--)
{
uint d;scanf("%u",&d);
if(d<=125)
{
if(Ans[d].size()==2)printf("2 %u %u\n",Ans[d][0],Ans[d][1]);
else if(Ans[d].size()==3)printf("3 %u %u %u\n",Ans[d][0],Ans[d][1],Ans[d][2]);
else puts("-1");
}
else
{
uint x=1;while(x*x*x<=d)x++;
uint y=x--;while(y*y<=d)y++;
while(!Prime[x])x--;
while(!Prime[y])y++;
printf("3 %u %u %u\n",x*y,x*y,x*y);
}
}
return 0;
}
// 那就是希望。
// 即便需要取模,也是光明。
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 30
Accepted
time: 1ms
memory: 3284kb
input:
30 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
output:
-1 -1 -1 -1 -1 -1 3 6 6 6 -1 -1 -1 3 9 10 10 3 9 10 10 3 9 10 10 -1 3 12 14 14 3 12 14 14 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 14 20 21 3 14 20 21 3 14 20 21 3 15 21 21 3 15 21 21 3 14 21 25 3 14 21 25
result:
ok ok (30 test cases)
Test #2:
score: 40
Accepted
time: 0ms
memory: 3176kb
input:
98 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
output:
-1 -1 -1 -1 -1 -1 3 6 6 6 -1 -1 -1 3 9 10 10 3 9 10 10 3 9 10 10 -1 3 12 14 14 3 12 14 14 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 14 20 21 3 14 20 21 3 14 20 21 3 15 21 21 3 15 21 21 3 14 21 25 3 14 21 25 3 10 28 28 3 10 28 28 3 10 28 28 3 14 28 28 3 14 28 28 3...
result:
ok ok (98 test cases)
Test #3:
score: 30
Accepted
time: 1ms
memory: 3148kb
input:
200 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
output:
-1 -1 -1 -1 -1 -1 3 6 6 6 -1 -1 -1 3 9 10 10 3 9 10 10 3 9 10 10 -1 3 12 14 14 3 12 14 14 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 10 15 15 3 14 20 21 3 14 20 21 3 14 20 21 3 15 21 21 3 15 21 21 3 14 21 25 3 14 21 25 3 10 28 28 3 10 28 28 3 10 28 28 3 14 28 28 3 14 28 28 3...
result:
ok ok (200 test cases)
Extra Test:
score: 0
Extra Test Passed