QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858405 | #4754. Balls | N_z_ | AC ✓ | 9ms | 3712kb | C++26 | 9.6kb | 2025-01-16 16:58:56 | 2025-01-16 16:58:58 |
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<<";along long_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 x=0;x<print_precision;x++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int x=0;x<print_precision-top;x++)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()
{
}
// #define double long double
void solve([[maybe_unused]]int tc)
{
int n=tc;
cin>>n;
if(n&1)
{
int nowp=0;
for(auto q:{3,13,31,57,93,137,187,247,315,391,475,567,667,775,893,1017,1151,1291,1441,1599,1765,1939,2121,2311,2509,2717,2931,3155,3385,3625,3873,4129,4393,4665,4945,5233,5529,5835,6147,6469,6799,7135,7481,7835,8197,8567,8945,9333,9727,10131,10541,10961,11389,11823,12267,12719,13179,13647,14125,14609,15101,15603,16113,16629,17155,17689,18231,18781,19339,19905,20481,21063,21655,22253,22861,23475,24099,24731,25371,26019,26677,27341,28013,28695,29383,30081,30787,31499,32221,32951,33689,34435,35191,35953,36723,37503,38291,39085,39889,40701,41521,42349,43185,44029,44881,45743,46611,47489,48375,49267,50169,51079,51997,52923,53857,54801,55751,56709,57677,58653,59635,60627,61627,62635,63651,64675,65707,66749,67797,68855,69919,70993,72075,73165,74261,75367,76483,77605,78735,79873,81021,82177,83339,84511,85691,86879,88075,89279,90491,91711,92939,94177,95421,96675,97937,99207,100483,101769,103063,104367,105677,106995,108323,109657,111001,112351,113711,115079,116455,117839,119231,120631,122039,123457,124881,126315,127755,129205,130663,132129,133603,135085,136575,138073,139581,141095,142619,144149,145689,147237,148793,150357,151929,153509,155097,156693,158299,159911,161533,163161,164799,166445,168099,169761,171431,173109,174795,176491,178193,179905,181623,183351,185087,186831,188583,190343,192111,193887,195673,197465,199267,200001})
{
if(n<q){cout<<nowp<<endl;return;}
nowp++;
}
cout<<"???"<<endl;
}
else
{
int nowp=0;
for(auto q:{2,6,16,30,48,72,100,130,166,208,252,302,356,414,476,544,614,690,770,854,944,1038,1134,1238,1344,1454,1570,1690,1814,1942,2074,2212,2354,2500,2650,2806,2964,3128,3296,3468,3646,3826,4012,4202,4396,4596,4800,5006,5218,5436,5656,5882,6110,6344,6584,6826,7074,7324,7580,7842,8106,8374,8648,8926,9208,9496,9786,10082,10382,10686,10996,11308,11626,11948,12274,12604,12940,13280,13624,13972,14324,14682,15044,15408,15780,16154,16532,16916,17304,17696,18094,18494,18900,19310,19724,20142,20566,20992,21424,21860,22302,22746,23196,23650,24108,24570,25038,25510,25984,26466,26950,27438,27932,28430,28932,29438,29950,30464,30984,31508,32038,32570,33108,33650,34196,34746,35300,35860,36424,36992,37564,38142,38722,39308,39898,40492,41092,41696,42302,42914,43532,44152,44778,45408,46042,46680,47322,47970,48622,49278,49938,50602,51272,51946,52624,53306,53992,54684,55380,56080,56784,57492,58206,58924,59646,60372,61102,61838,62578,63322,64070,64822,65580,66342,67108,67878,68652,69432,70214,71002,71796,72592,73392,74198,75008,75822,76642,77464,78292,79124,79960,80800,81646,82496,83350,84208,85070,85938,86808,87684,88564,89450,90338,91232,92130,93032,93938,94850,95764,96684,97608,98538,99470,100408,101350,102296,103246,104202,105160,106124,107092,108066,109042,110024,111010,112000,112994,113994,114996,116004,117016,118032,119054,120080,121108,122142,123182,124224,125272,126324,127380,128440,129504,130574,131648,132726,133808,134896,135986,137082,138182,139286,140396,141508,142626,143748,144874,146006,147140,148280,149424,150572,151726,152882,154044,155210,156380,157556,158734,159918,161106,162298,163496,164696,165902,167112,168326,169546,170768,171996,173228,174464,175706,176950,178200,179454,180712,181974,183242,184514,185790,187070,188354,189644,190936,192234,193536,194844,196154,197470,198790,200001})
{
if(n<q){cout<<nowp<<endl;return;}
nowp++;
}
cout<<"???"<<endl;
}
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
5 2 3 6 7 8
output:
1 1 2 1 2
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 5ms
memory: 3712kb
input:
100000 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 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...
output:
1 1 1 1 2 1 2 1 2 1 2 2 2 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 5 3 5 3 5 3 5 3 5 4 5 4 5 4 5 4 5 4 5 4 5 4 5 4 6 4 6 4 6 4 6 4 6 4 6 4 6 4 6 4 6 4 6 4 6 5 6 5 6 5 6 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 8 5 8 5 8 5 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 ...
result:
ok 100000 lines
Test #3:
score: 0
Accepted
time: 9ms
memory: 3584kb
input:
100000 100001 100002 100003 100004 100005 100006 100007 100008 100009 100010 100011 100012 100013 100014 100015 100016 100017 100018 100019 100020 100021 100022 100023 100024 100025 100026 100027 100028 100029 100030 100031 100032 100033 100034 100035 100036 100037 100038 100039 100040 100041 100042...
output:
156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 213 156 ...
result:
ok 100000 lines
Extra Test:
score: 0
Extra Test Passed