QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#386547 | #7526. Credit Cards | Crysfly | AC ✓ | 227ms | 38840kb | C++17 | 3.0kb | 2024-04-11 18:07:57 | 2024-04-11 18:07:57 |
Judging History
answer
// what is matter? never mind.
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,modint b){return a.x==b.x;}
friend bool operator !=(modint a,modint b){return a.x!=b.x;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 2000005
#define inf 0x3f3f3f3f
int n;
int a[maxn][3];
bool vis[maxn];
signed main()
{
n=read();
int p=1;
int k=(n-1)/3;
int now=n,now2=n-1;
set<int>s;
For(i,k+2,n) s.insert(i);
// long long cs=0;
Rep(id,k,1){
a[id][0]=id+1;
int now=*s.rbegin();
int now2=now-1;
// while(vis[now2] || 1ll*a[id][0]*a[id][0]+1ll*now2*now2>=1ll*now*now) --now2,++cs;
ll tmp=1ll*now*now-1ll*(id+1)*(id+1);
tmp=floor(sqrtl(tmp));
now2=(*(--s.upper_bound(tmp)));
s.erase(now),s.erase(now2);
a[id][1]=now2;
a[id][2]=now;
// if(id%10000==1) cerr<<"cs "<<cs<<"\n";
}
cout<<k<<"\n";
For(i,1,k)For(j,0,2)cout<<a[i][j]<<" \n"[j==2];
return 0;
}
/*
*/
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
3
output:
0
result:
ok OK 0 triangles!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
4
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
9
output:
2 2 6 7 3 8 9
result:
ok OK 2 triangles!
Test #4:
score: 0
Accepted
time: 227ms
memory: 38840kb
input:
1000000
output:
333333 2 333335 333336 3 333337 333338 4 333339 333340 5 333341 333342 6 333343 333344 7 333345 333346 8 333347 333348 9 333349 333350 10 333351 333352 11 333353 333354 12 333355 333356 13 333357 333358 14 333359 333360 15 333361 333362 16 333363 333364 17 333365 333366 18 333367 333368 19 333369 33...
result:
ok OK 333333 triangles!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1
output:
0
result:
ok OK 0 triangles!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
2
output:
0
result:
ok OK 0 triangles!
Test #7:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
5
output:
1 2 4 5
result:
ok OK 1 triangles!
Test #8:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
6
output:
1 2 5 6
result:
ok OK 1 triangles!
Test #9:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
7
output:
2 2 4 5 3 6 7
result:
ok OK 2 triangles!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
8
output:
2 2 5 6 3 7 8
result:
ok OK 2 triangles!
Test #11:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
10
output:
3 2 5 6 3 7 8 4 9 10
result:
ok OK 3 triangles!
Test #12:
score: 0
Accepted
time: 134ms
memory: 25420kb
input:
621316
output:
207105 2 207107 207108 3 207109 207110 4 207111 207112 5 207113 207114 6 207115 207116 7 207117 207118 8 207119 207120 9 207121 207122 10 207123 207124 11 207125 207126 12 207127 207128 13 207129 207130 14 207131 207132 15 207133 207134 16 207135 207136 17 207137 207138 18 207139 207140 19 207141 20...
result:
ok OK 207105 triangles!
Test #13:
score: 0
Accepted
time: 161ms
memory: 28672kb
input:
713171
output:
237723 2 237726 237727 3 237728 237729 4 237730 237731 5 237732 237733 6 237734 237735 7 237736 237737 8 237738 237739 9 237740 237741 10 237742 237743 11 237744 237745 12 237746 237747 13 237748 237749 14 237750 237751 15 237752 237753 16 237754 237755 17 237756 237757 18 237758 237759 19 237760 23...
result:
ok OK 237723 triangles!
Test #14:
score: 0
Accepted
time: 165ms
memory: 32628kb
input:
825609
output:
275202 2 275206 275207 3 275208 275209 4 275210 275211 5 275212 275213 6 275214 275215 7 275216 275217 8 275218 275219 9 275220 275221 10 275222 275223 11 275224 275225 12 275226 275227 13 275228 275229 14 275230 275231 15 275232 275233 16 275234 275235 17 275236 275237 18 275238 275239 19 275240 27...
result:
ok OK 275202 triangles!
Test #15:
score: 0
Accepted
time: 189ms
memory: 31124kb
input:
782282
output:
260760 2 260763 260764 3 260765 260766 4 260767 260768 5 260769 260770 6 260771 260772 7 260773 260774 8 260775 260776 9 260777 260778 10 260779 260780 11 260781 260782 12 260783 260784 13 260785 260786 14 260787 260788 15 260789 260790 16 260791 260792 17 260793 260794 18 260795 260796 19 260797 26...
result:
ok OK 260760 triangles!
Test #16:
score: 0
Accepted
time: 22ms
memory: 8684kb
input:
148128
output:
49375 2 49379 49380 3 49381 49382 4 49383 49384 5 49385 49386 6 49387 49388 7 49389 49390 8 49391 49392 9 49393 49394 10 49395 49396 11 49397 49398 12 49399 49400 13 49401 49402 14 49403 49404 15 49405 49406 16 49407 49408 17 49409 49410 18 49411 49412 19 49413 49414 20 49415 49416 21 49417 49418 22...
result:
ok OK 49375 triangles!
Test #17:
score: 0
Accepted
time: 142ms
memory: 27780kb
input:
681282
output:
227093 2 227097 227098 3 227099 227100 4 227101 227102 5 227103 227104 6 227105 227106 7 227107 227108 8 227109 227110 9 227111 227112 10 227113 227114 11 227115 227116 12 227117 227118 13 227119 227120 14 227121 227122 15 227123 227124 16 227125 227126 17 227127 227128 18 227129 227130 19 227131 22...
result:
ok OK 227093 triangles!
Test #18:
score: 0
Accepted
time: 174ms
memory: 31676kb
input:
798547
output:
266182 2 266184 266185 3 266186 266187 4 266188 266189 5 266190 266191 6 266192 266193 7 266194 266195 8 266196 266197 9 266198 266199 10 266200 266201 11 266202 266203 12 266204 266205 13 266206 266207 14 266208 266209 15 266210 266211 16 266212 266213 17 266214 266215 18 266216 266217 19 266218 26...
result:
ok OK 266182 triangles!
Test #19:
score: 0
Accepted
time: 70ms
memory: 15972kb
input:
349290
output:
116429 2 116433 116434 3 116435 116436 4 116437 116438 5 116439 116440 6 116441 116442 7 116443 116444 8 116445 116446 9 116447 116448 10 116449 116450 11 116451 116452 12 116453 116454 13 116455 116456 14 116457 116458 15 116459 116460 16 116461 116462 17 116463 116464 18 116465 116466 19 116467 11...
result:
ok OK 116429 triangles!
Test #20:
score: 0
Accepted
time: 63ms
memory: 14848kb
input:
317275
output:
105758 2 105760 105761 3 105762 105763 4 105764 105765 5 105766 105767 6 105768 105769 7 105770 105771 8 105772 105773 9 105774 105775 10 105776 105777 11 105778 105779 12 105780 105781 13 105782 105783 14 105784 105785 15 105786 105787 16 105788 105789 17 105790 105791 18 105792 105793 19 105794 10...
result:
ok OK 105758 triangles!
Test #21:
score: 0
Accepted
time: 14ms
memory: 7080kb
input:
100000
output:
33333 2 33335 33336 3 33337 33338 4 33339 33340 5 33341 33342 6 33343 33344 7 33345 33346 8 33347 33348 9 33349 33350 10 33351 33352 11 33353 33354 12 33355 33356 13 33357 33358 14 33359 33360 15 33361 33362 16 33363 33364 17 33365 33366 18 33367 33368 19 33369 33370 20 33371 33372 21 33373 33374 22...
result:
ok OK 33333 triangles!
Test #22:
score: 0
Accepted
time: 10ms
memory: 6544kb
input:
83568
output:
27855 2 27859 27860 3 27861 27862 4 27863 27864 5 27865 27866 6 27867 27868 7 27869 27870 8 27871 27872 9 27873 27874 10 27875 27876 11 27877 27878 12 27879 27880 13 27881 27882 14 27883 27884 15 27885 27886 16 27887 27888 17 27889 27890 18 27891 27892 19 27893 27894 20 27895 27896 21 27897 27898 22...
result:
ok OK 27855 triangles!
Test #23:
score: 0
Accepted
time: 7ms
memory: 5148kb
input:
41476
output:
13825 2 13827 13828 3 13829 13830 4 13831 13832 5 13833 13834 6 13835 13836 7 13837 13838 8 13839 13840 9 13841 13842 10 13843 13844 11 13845 13846 12 13847 13848 13 13849 13850 14 13851 13852 15 13853 13854 16 13855 13856 17 13857 13858 18 13859 13860 19 13861 13862 20 13863 13864 21 13865 13866 22...
result:
ok OK 13825 triangles!
Test #24:
score: 0
Accepted
time: 5ms
memory: 5660kb
input:
61028
output:
20342 2 20345 20346 3 20347 20348 4 20349 20350 5 20351 20352 6 20353 20354 7 20355 20356 8 20357 20358 9 20359 20360 10 20361 20362 11 20363 20364 12 20365 20366 13 20367 20368 14 20369 20370 15 20371 20372 16 20373 20374 17 20375 20376 18 20377 20378 19 20379 20380 20 20381 20382 21 20383 20384 22...
result:
ok OK 20342 triangles!
Test #25:
score: 0
Accepted
time: 2ms
memory: 4692kb
input:
34231
output:
11410 2 11412 11413 3 11414 11415 4 11416 11417 5 11418 11419 6 11420 11421 7 11422 11423 8 11424 11425 9 11426 11427 10 11428 11429 11 11430 11431 12 11432 11433 13 11434 11435 14 11436 11437 15 11438 11439 16 11440 11441 17 11442 11443 18 11444 11445 19 11446 11447 20 11448 11449 21 11450 11451 22...
result:
ok OK 11410 triangles!
Test #26:
score: 0
Accepted
time: 2ms
memory: 3960kb
input:
10000
output:
3333 2 3335 3336 3 3337 3338 4 3339 3340 5 3341 3342 6 3343 3344 7 3345 3346 8 3347 3348 9 3349 3350 10 3351 3352 11 3353 3354 12 3355 3356 13 3357 3358 14 3359 3360 15 3361 3362 16 3363 3364 17 3365 3366 18 3367 3368 19 3369 3370 20 3371 3372 21 3373 3374 22 3375 3376 23 3377 3378 24 3379 3380 25 3...
result:
ok OK 3333 triangles!
Test #27:
score: 0
Accepted
time: 2ms
memory: 4064kb
input:
8370
output:
2789 2 2793 2794 3 2795 2796 4 2797 2798 5 2799 2800 6 2801 2802 7 2803 2804 8 2805 2806 9 2807 2808 10 2809 2810 11 2811 2812 12 2813 2814 13 2815 2816 14 2817 2818 15 2819 2820 16 2821 2822 17 2823 2824 18 2825 2826 19 2827 2828 20 2829 2830 21 2831 2832 22 2833 2834 23 2835 2836 24 2837 2838 25 2...
result:
ok OK 2789 triangles!
Test #28:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
5858
output:
1952 2 1955 1956 3 1957 1958 4 1959 1960 5 1961 1962 6 1963 1964 7 1965 1966 8 1967 1968 9 1969 1970 10 1971 1972 11 1973 1974 12 1975 1976 13 1977 1978 14 1979 1980 15 1981 1982 16 1983 1984 17 1985 1986 18 1987 1988 19 1989 1990 20 1991 1992 21 1993 1994 22 1995 1996 23 1997 1998 24 1999 2000 25 2...
result:
ok OK 1952 triangles!
Test #29:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
688
output:
229 2 231 232 3 233 234 4 235 236 5 237 238 6 239 240 7 241 242 8 243 244 9 245 246 10 247 248 11 249 250 12 251 252 13 253 254 14 255 256 15 257 258 16 259 260 17 261 262 18 263 264 19 265 266 20 267 268 21 269 270 22 271 272 23 273 275 24 274 276 25 277 279 26 278 280 27 281 283 28 282 284 29 285 ...
result:
ok OK 229 triangles!
Test #30:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
6480
output:
2159 2 2163 2164 3 2165 2166 4 2167 2168 5 2169 2170 6 2171 2172 7 2173 2174 8 2175 2176 9 2177 2178 10 2179 2180 11 2181 2182 12 2183 2184 13 2185 2186 14 2187 2188 15 2189 2190 16 2191 2192 17 2193 2194 18 2195 2196 19 2197 2198 20 2199 2200 21 2201 2202 22 2203 2204 23 2205 2206 24 2207 2208 25 2...
result:
ok OK 2159 triangles!
Test #31:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1000
output:
333 2 335 336 3 337 338 4 339 340 5 341 342 6 343 344 7 345 346 8 347 348 9 349 350 10 351 352 11 353 354 12 355 356 13 357 358 14 359 360 15 361 362 16 363 364 17 365 366 18 367 368 19 369 370 20 371 372 21 373 374 22 375 376 23 377 378 24 379 380 25 381 382 26 383 384 27 385 387 28 386 388 29 389 ...
result:
ok OK 333 triangles!
Test #32:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
491
output:
163 2 166 167 3 168 169 4 170 171 5 172 173 6 174 175 7 176 177 8 178 179 9 180 181 10 182 183 11 184 185 12 186 187 13 188 189 14 190 191 15 192 193 16 194 195 17 196 197 18 198 199 19 200 201 20 202 204 21 203 205 22 206 208 23 207 209 24 210 212 25 211 213 26 214 216 27 215 217 28 218 221 29 219 ...
result:
ok OK 163 triangles!
Test #33:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
667
output:
222 2 224 225 3 226 227 4 228 229 5 230 231 6 232 233 7 234 235 8 236 237 9 238 239 10 240 241 11 242 243 12 244 245 13 246 247 14 248 249 15 250 251 16 252 253 17 254 255 18 256 257 19 258 259 20 260 261 21 262 263 22 264 265 23 266 268 24 267 269 25 270 272 26 271 273 27 274 276 28 275 277 29 278 ...
result:
ok OK 222 triangles!
Test #34:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
63
output:
20 2 24 25 3 26 27 4 28 29 5 30 31 6 32 33 7 34 35 8 36 38 9 37 39 10 40 42 11 41 43 12 44 47 13 45 48 14 46 49 15 50 53 16 51 54 17 52 55 18 56 60 19 57 61 20 58 62 21 59 63
result:
ok OK 20 triangles!
Test #35:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
682
output:
227 2 229 230 3 231 232 4 233 234 5 235 236 6 237 238 7 239 240 8 241 242 9 243 244 10 245 246 11 247 248 12 249 250 13 251 252 14 253 254 15 255 256 16 257 258 17 259 260 18 261 262 19 263 264 20 265 266 21 267 268 22 269 270 23 271 273 24 272 274 25 275 277 26 276 278 27 279 281 28 280 282 29 283 ...
result:
ok OK 227 triangles!
Test #36:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
100
output:
33 2 35 36 3 37 38 4 39 40 5 41 42 6 43 44 7 45 46 8 47 48 9 49 50 10 51 53 11 52 54 12 55 57 13 56 58 14 59 62 15 60 63 16 61 64 17 65 68 18 66 69 19 67 70 20 71 75 21 72 76 22 73 77 23 74 78 24 79 84 25 80 85 26 81 86 27 82 87 28 83 88 29 89 95 30 90 96 31 91 97 32 92 98 33 93 99 34 94 100
result:
ok OK 33 triangles!
Test #37:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
38
output:
12 2 15 16 3 17 18 4 19 20 5 21 22 6 23 24 7 25 27 8 26 28 9 29 31 10 30 32 11 33 36 12 34 37 13 35 38
result:
ok OK 12 triangles!
Test #38:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
167
output:
55 2 58 59 3 60 61 4 62 63 5 64 65 6 66 67 7 68 69 8 70 71 9 72 73 10 74 75 11 76 77 12 78 80 13 79 81 14 82 84 15 83 85 16 86 88 17 87 89 18 90 93 19 91 94 20 92 95 21 96 99 22 97 100 23 98 101 24 102 106 25 103 107 26 104 108 27 105 109 28 110 115 29 111 116 30 112 117 31 113 118 32 114 119 33 120...
result:
ok OK 55 triangles!
Test #39:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
34
output:
11 2 13 14 3 15 16 4 17 18 5 19 20 6 21 23 7 22 24 8 25 27 9 26 28 10 29 32 11 30 33 12 31 34
result:
ok OK 11 triangles!