QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#832931 | #9842. Module | N_z_ | AC ✓ | 1ms | 4092kb | C++23 | 6.6kb | 2024-12-26 11:11:28 | 2024-12-26 11:11:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct time_helper{
#ifdef LOCAL
clock_t time_last;time_helper(){time_last=clock();}void test(){auto time_now=clock();std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;time_last=time_now;}~time_helper(){test();}
#else
void test(){}
#endif
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
int print_precision=10;bool print_T_endl=1;char print_between=' ';
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader;struct Writer;template<size_t id>struct read_tuple{template<typename...T>static void read(Reader&stream,std::tuple<T...>&x){read_tuple<id-1>::read(stream,x);stream>>get<id-1>(x);}};template<>struct read_tuple<0>{template<typename...T>static void read([[maybe_unused]]Reader&stream,[[maybe_unused]]std::tuple<T...>&x){}};template<size_t id>struct print_tuple{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){print_tuple<id-1>::print(stream,x);putchar(print_between);stream<<get<id-1>(x);}};template<>struct print_tuple<1>{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){stream<<get<0>(x);}};template<>struct print_tuple<0>{template<typename...T>static void print([[maybe_unused]]Writer&stream,[[maybe_unused]]const std::tuple<T...>&x){}};
struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename...T>Reader&operator>>(std::tuple<T...>&x){read_tuple<sizeof...(T)>::read(*this,x);return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}template<typename T1,typename T2>Reader&operator>>(std::pair<T1,T2>&x){*this>>x.first>>x.second;return *this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';
struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(const T&x){for(auto q:x){*this<<q;if(!is_class<decltype(q)>::value)*this<<print_between;}if(!is_class<typename T::value_type>::value&&print_T_endl)*this<<'\n';return *this;}template<typename...T>Writer&operator<<(const std::tuple<T...>&x){print_tuple<sizeof...(T)>::print(*this,x);if(print_T_endl)*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-print_precision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<print_precision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<print_precision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(const T&c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}template<typename T1,typename T2>Writer&operator<<(const std::pair<T1,T2>&x){*this<<x.first<<print_between<<x.second;if(print_T_endl)*this<<'\n';return *this;}Writer&operator<<(const std::string&str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<class Fun>class y_combinator_result{Fun fun_;public:template<class T>explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}template<class ...Args>decltype(auto) operator()(Args &&...args){return fun_(std::ref(*this), std::forward<Args>(args)...);}};template<class Fun>decltype(auto) y_combinator(Fun &&fun){return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}
void init();void solve(int tc);
signed main()
{
init();int t=1;
// cin>>t;
for(int tc=1;tc<=t;tc++)solve(tc);
}
void init()
{
}
void solve([[maybe_unused]]int tc)
{
int n;
cin>>n;
vector<long long>a(n);
cin>>a;
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
long long v;
cin>>v;
vector<long long>res{v};
for(int x=0;x+1<n;x++)
{
for(int y=res.size()-1;y>=0;y--)
if(res[y]>a[x])
res.emplace_back(res[y]%a[x]);
}
long long ans=0;
for(auto q:res)ans=max(ans,q%a.back());
cout<<ans<<endl;
}
/*
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
3 5 6 7 15
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
4 20 21 22 10 107
output:
9
result:
ok single line: '9'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
5 5 6 7 8 9 1000000000000
output:
4
result:
ok single line: '4'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
21 387370091048596 23758943242091 1014205329284566 1140429273127661 47646521198630614 18199351186587118 140264880946836239 2655245896805102 56344740535070 6951532361130740 7919647866064 7816692309555091 147904943861222 2985707194227584 20464369734437689 7043092696894 166312602338536 21129277743988 4...
output:
7040631923013
result:
ok single line: '7040631923013'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
21 247510449291217 11628490926442390 434735492705046 4500190244809 13500570059509 20424663875119041 53472465601849629 36001519933718 23712845183334 7904282018121 4441687517182397 7801526023507494 1696571625104801 2979914195403441 63234253531881 30443785262144773 1138216562702829 648027358132006 1399...
output:
4499821809855
result:
ok single line: '4499821809855'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
21 153865317269531 9798845110964597 58748575692624 2761183057119159 1429618739596321 175833177062094089 8392653732399 7228872360279101 3742821283520306 67162297037155858 9927908253394 208486066209650 22380409808341 402847376115969 25653714049373485 18925434023718144 29783723871229 546034935268657 79...
output:
2793876215767
result:
ok single line: '2793876215767'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
21 211791254487299 3850750382216 203391993130760 9555725640815081 11552250359287 80865751727648 3800690330412095 77658761017939 29584289923057 532517218374341 30806000695645 11094108751232 9950338210520837 3698036330639 25017215154842795 26050324301150416 1451732780715448 68200634692930411 554508011...
output:
3697696074736
result:
ok single line: '3697696074736'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
21 2874654974287610 215876191314313 61189995018758 10142255969952640 11775065041661 8923540944682 1274791594016 23371178654480 1479733165895279 3925021820071 31400173304912 419406424186624 7525944456704752 1098020466158078 82425454873075 26552771531241947 160198806401794 565203119069864 424930602482...
output:
424871944746
result:
ok single line: '424871944746'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
21 4644812482582 786810230 12160276957375 2098062763 1774160490371 669941730030186 14424071414 5507378059 677668988531 258846475222 262367927 12058951139787202 83742716537328 83347778211254 1758597041234720 98870437135 218207316244219 4605849393673974 37764836183 251228148855838 31836018389543 19512...
output:
262339846
result:
ok single line: '262339846'
Test #10:
score: 0
Accepted
time: 1ms
memory: 4092kb
input:
21 106616697621293 866859543662 15555166538206 40723954719833 4024560973627004 730761716810845 7026249133 5941544894785 10540516835662264 1533166085218748 191645760868972 2269468146149 2634915118 18443832281 27596989533359788 48305247710 878496221 574937282029240 279126138144046 331110484837 1264719...
output:
878310536
result:
ok single line: '878310536'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
21 969193328243 17445301082151 4910390705588 33658479950437 603977757209777 45672766174616 6663137071837 1874881898089 12856290218675 119572997441697 121216225864 313046226150475 89394215165 714254988679 88119149632636 2145650816878709 819565681009728 2544110133360 363469851369 267883067948 23069896...
output:
89371596948
result:
ok single line: '89371596948'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
21 1578283232271824 891048836434 4899334188112 602850535480128 33595386908096 1866428865600 2376032247880 87954587025552 4131999161335344 2009218417321942 230268374168560 297114261422 293140957690850 16335111473738 42768286514008 6237047907206 699952408688 111969748068286 233428360464 76745312500426...
output:
233226691356
result:
ok single line: '233226691356'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
21 4563397251513 214478880883272 1543639013482 72742019020252 11951717090256 561513097682307 4051958625148 190441305100018 27784751960738 3848668138808640 1738474664283 1470060412163649 193236232412 31291754019255 578958415298 652026741336 217605559725 10612236861962 81923544967509 1305304383739388 ...
output:
193220937045
result:
ok single line: '193220937045'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
21 1864864975726 914694094546416 6269407850631219 926873323127 7413953093929 2780275472352 33478505570446 1572779304445987 349381635246703 600748235292302 4884137562203 87647969000455 2394700648392545 710457364975 50970798334376 133450811193693 89063992622 19461583809435 266507119199 229465401430919...
output:
89050113741
result:
ok single line: '89050113741'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3932kb
input:
21 1341445020291270 55181844895712 990207506501296 195714151633695 378225545549950 21076404538582 28554041144595 4164136378470 2592396973953938 512386390641655 8047368720034 594913504695 74756064259430 1149736144526 144469130148554 10906059174355 1586349961055 198390553030 383506812058 3511948670232...
output:
198218583513
result:
ok single line: '198218583513'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
21 11483915273577 640991875905 4335874906251421 1656156800875398 78716974028409 241629688248921 626515939821 632595496374773 5127429820422 3698027346448593 539534902925286 1922807232109 4384782720069 1412520749791293 1670432886630 92293568371990 30066963100662 13459482229157 35251016867049 209114932...
output:
208907003536
result:
ok single line: '208907003536'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
21 7013544528945 1022824625025 2678789717990 824033280072645 125854117363925 146227846230 329490365014185 314752327170787 2157347513047148 2504708597853 835012925819 389684157085 5648009259068799 862616977678630 18361843868845 120223701439716 17532630005367 6679112867740 45918777148361 4807198707759...
output:
48960202815
result:
ok single line: '48960202815'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
21 2051483688271 15524331268644 40643556347069 783309247828 108103595941 298444055213 278575456970620 252331642480484 729320033139297 37624698220 862505864972 1909384642447271 112022917811 5371141816985 2263981107945 14061941762684 96382108650517 36814683471067 323536486971 5929437458863 10640633777...
output:
37612574167
result:
ok single line: '37612574167'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
21 448200986296 21513391730236 1561978159629 28115252470305 192706618923486 56323254484604 149412500764 195380171085 73607290464597 1010681210334796 585786110238 504512566305861 3457980673676430 3137370388076 386045860686124 147456371723576 10738466946318 4100148368649 1320831079994097 8216920706104...
output:
149328224347
result:
ok single line: '149328224347'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
21 2617750667441 123360401556098 72941207135502 2213615684824258 499946571647871 10641878300643 27861028478715 322962111186569 327375783010 1308877122015822 47119093481725 6871543185506 845525932003609 4064606423214 591216483783 73908963267 1551940968999 190962592927791 17996878889077 981708816817 2...
output:
73898808158
result:
ok single line: '73898808158'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
21 1287402011465 372859294056689 1133352604681 142419406428629 2555616133167625 23503403585 60484391135270 414566196068785 3022178384126 187272202150 491558071205 54398925229198 158350195734685 8824541878105 976158475741438 20777369258965 7933182547697 3370647963190 70258535245 23102977671125 377879...
output:
23500121538
result:
ok single line: '23500121538'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
21 213175981820311 204947599074 68509282287 176455280863839 31099946561288 3755825322258 1696402102784 558102636000400 1209442522306002 4523644108705 25744443740871 67399908201570 461965934389947 81425309460533 3825293142542267 9833423021043 11874530223331 565562199647 546333514935 1461131926180889 ...
output:
68421148932
result:
ok single line: '68421148932'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
21 21499517784 18405409940329 1025691259653 2685310464911 618631574198 232039583197 4252933843993 1623855139397 77487175393 391763314048 1369520919112193 29151905333753 199810403492278 76320769608677 11134946392582 523110440868157 7465819927 7030240135080 149598682491 48185989685907 57032733425 2215...
output:
7459696341
result:
ok single line: '7459696341'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
21 43653096884289 783374596066293 6349567554627 793875998100 40567085240600 107698511608 2259710208456 15495120741282 114291735839895 2381147850909 16667554812972 278051319700954 860853642122 2050901677563483 5918276983246 1905792152666078 727947824122344 106206134980518 322850717910 299222110635396...
output:
107688376038
result:
ok single line: '107688376038'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
21 30519081447135 188948133232 3753634752907650 1278206804160544 566833828042 186487821986426 27207949744438 1433760888954687 3967826224640 209182852914546 212265089955 71231923910288 4450717215399 1695552092019 547647913956411 488231542048990 635939060658 10391925323026 11656599554178 1511553350894...
output:
188933962165
result:
ok single line: '188933962165'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
21 67700196998784 25858963176209 420748955941 60549677339179 3363909521183 3771114413320 177241627820143 179862440976 1436650710117 1086530282584039 2844573282115705 158522414325197 9876692529843 23126617692340 1261552825708 1214832431564792 538837717031 8830175737841 464024686461645 415017565636412...
output:
179801362284
result:
ok single line: '179801362284'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
21 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152
output:
0
result:
ok single line: '0'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1 1000000000000000000 1000000000000000000
output:
0
result:
ok single line: '0'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
1 999999999999999999 1000000000000000000
output:
1
result:
ok single line: '1'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1000000000000000000 999999999999999999
output:
999999999999999999
result:
ok single line: '999999999999999999'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Extra Test:
score: 0
Extra Test Passed