QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#857985 | #9675. 电池检测 | XY_Eleven | 100 ✓ | 1ms | 3840kb | C++20 | 3.8kb | 2025-01-16 11:51:04 | 2025-01-16 11:51:05 |
Judging History
answer
#include <bits/stdc++.h>
// #include <windows.h>
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
//#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define in128 __int128
#define cint const int
#define cLL const LL
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outint2_(e,e1,e2) printf("%d%c",e," \n"[(e1)==(e2)])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define outll2_(e,e1,e2) printf("%lld%c",e," \n"[(e1)==(e2)])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) (1ll*(e))
#define pb push_back
#define ft first
#define sc second
#define pii pair<int,int>
#define pli pair<long long,int>
#define vct vector
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define sz(ev) ((int)ev.size())
#define debug(x) printf("%s=%d\n",#x,x)
#define x0 __xx00__
#define y1 __yy11__
#define ffo fflush(stdout)
cLL mod=998244353,G=404;
// cLL mod[2]={1686688681ll,1666888681ll},base[2]={166686661ll,188868881ll};
template <typename Type> void get_min(Type &w1,const Type w2) { if(w2<w1) w1=w2; } template <typename Type> void get_max(Type &w1,const Type w2) { if(w2>w1) w1=w2; }
template <typename Type> Type up_div(Type w1,Type w2) { return (w1/w2+(w1%w2?1:0)); }
template <typename Type> Type gcd(Type X_,Type Y_) { Type R_=X_%Y_; while(R_) { X_=Y_; Y_=R_; R_=X_%Y_; } return Y_; } template <typename Type> Type lcm(Type X_,Type Y_) { return (X_/gcd(X_,Y_)*Y_); }
template <typename Type> Type md(Type w1,const Type w2=mod) { w1%=w2; if(w1<0) w1+=w2; return w1; } template <typename Type> Type md_(Type w1,const Type w2=mod) { w1%=w2; if(w1<=0) w1+=w2; return w1; }
void ex_gcd(LL &X_,LL &Y_,LL A_,LL B_) { if(!B_) { X_=1ll; Y_=0ll; return ; } ex_gcd(Y_,X_,B_,A_%B_); X_=md(X_,B_); Y_=(1ll-X_*A_)/B_; } LL inv(LL A_,LL B_=mod) { LL X_=0ll,Y_=0ll; ex_gcd(X_,Y_,A_,B_); return X_; }
template <typename Type> void add(Type &w1,const Type w2,const Type M_=mod) { w1=md(w1+w2,M_); } void mul(LL &w1,cLL w2,cLL M_=mod) { w1=md(w1*md(w2,M_),M_); } template <typename Type> Type pw(Type X_,Type Y_,Type M_=mod) { Type S_=1; while(Y_) { if(Y_&1) mul(S_,X_,M_); Y_>>=1; mul(X_,X_,M_); } return S_; }
template <typename Type> Type bk(vector <Type> &V_) { auto T_=V_.back(); V_.pop_back(); return T_; } template <typename Type> Type tp(stack <Type> &V_) { auto T_=V_.top(); V_.pop(); return T_; } template <typename Type> Type frt(queue <Type> &V_) { auto T_=V_.front(); V_.pop(); return T_; }
template <typename Type> Type bg(set <Type> &V_) { auto T_=*V_.begin(); V_.erase(V_.begin()); return T_; } template <typename Type> Type bk(set <Type> &V_) { auto T_=*prev(V_.end()); V_.erase(*prev(V_.end())); return T_; }
mt19937 gen(time(NULL)); int rd() { return abs((int)gen()); }
int rnd(int l,int r) { return rd()%(r-l+1)+l; }
void main_init()
{
}
void main_solve()
{
int n,m; inpr(m,n);
n+=m; m--;
// printf("%d %d\n",n,m);
int w1=n/m,w2=w1+1,t2=n%m,t1=m-t2;
printf("%d\n",t1*(w1*(w1-1)/2)+t2*(w2*(w2-1)/2));
}
int main()
{
// ios::sync_with_stdio(0); cin.tie(0);
// freopen("ex_block4.in","r",stdin);
// freopen("out.txt","w",stdout);
// srand(time(NULL));
main_init();
int _; inint(_); For(__,1,_) // T>1 ?
// printf("\n------------\n\n"),
main_solve();
// cerr<<clock()<<'\n';
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
3 2 1 3 1 2 2
output:
3 2 6
result:
ok 3 number(s): "3 2 6"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
12 2 1 2 2 2 3 2 4 3 1 3 2 3 3 3 4 4 1 4 2 4 3 4 4
output:
3 6 10 15 2 4 6 9 2 3 5 7
result:
ok 12 numbers
Subtask #2:
score: 5
Accepted
Test #3:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
1000 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61...
output:
3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 561 595 630 666 703 741 780 820 861 903 946 990 1035 1081 1128 1176 1225 1275 1326 1378 1431 1485 1540 1596 1653 1711 1770 1830 1891 1953 2016 2080 2145 2211 2278 2346 2415 2485 2556 2628 27...
result:
ok 1000 numbers
Subtask #3:
score: 10
Accepted
Test #4:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
1000 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61...
output:
2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 15...
result:
ok 1000 numbers
Subtask #4:
score: 5
Accepted
Test #5:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
1000 907 241 495 435 227 139 616 1 433 35 588 407 533 322 995 961 748 310 212 36 968 500 294 187 375 371 307 14 648 180 122 28 304 253 818 812 41 5 286 62 573 340 547 224 347 35 279 56 151 85 626 410 456 248 578 470 11 6 952 771 404 302 77 27 168 40 524 517 171 147 407 294 268 106 100 27 549 196 973...
output:
242 436 140 2 36 408 323 962 311 37 501 188 372 15 181 29 254 813 6 63 341 225 36 57 86 411 249 471 7 772 303 28 41 518 148 295 107 28 197 374 35 337 236 92 714 832 465 377 70 496 141 52 38 47 632 355 96 329 130 395 233 124 815 408 201 20 56 630 544 62 379 618 415 17 131 265 179 232 316 109 60 266 7...
result:
ok 1000 numbers
Subtask #5:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 20
Accepted
time: 0ms
memory: 3840kb
input:
90 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 6 10 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 7 10 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 8 10 9 1 9 2 9 ...
output:
3 6 10 15 21 28 36 45 55 66 2 4 6 9 12 16 20 25 30 36 2 3 5 7 9 12 15 18 22 26 2 3 4 6 8 10 12 15 18 21 2 3 4 5 7 9 11 13 15 18 2 3 4 5 6 8 10 12 14 16 2 3 4 5 6 7 9 11 13 15 2 3 4 5 6 7 8 10 12 14 2 3 4 5 6 7 8 9 11 13
result:
ok 90 numbers
Subtask #6:
score: 30
Accepted
Dependency #5:
100%
Accepted
Test #7:
score: 30
Accepted
time: 1ms
memory: 3840kb
input:
870 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 4 1 4 2 4 3 4 ...
output:
3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 2 3 5 7 9 12 15 18 22 26 30 35 40 45 51 57 63 70 77 84 92 100 108 117 126 135 145 155 165 176 2...
result:
ok 870 numbers
Subtask #7:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Test #8:
score: 20
Accepted
time: 0ms
memory: 3840kb
input:
1000 52 422 611 532 356 636 518 831 382 597 647 316 508 822 258 125 66 377 211 468 505 652 438 313 649 864 520 224 776 267 446 968 750 22 531 957 785 248 955 526 847 610 704 463 963 1 710 433 408 384 658 581 769 363 633 845 870 100 906 995 511 561 435 640 334 732 606 766 520 690 511 126 121 229 97 7...
output:
1971 533 919 1147 815 317 1139 126 1293 777 802 314 1082 225 268 1572 23 1386 249 527 611 464 2 434 385 582 364 1060 101 1087 614 848 1200 929 863 127 340 3112 219 375 741 49 96 27 838 289 748 650 8352 1112 554 201 282 250 785 1562 1275 277 95703 362 53 287 1432 61 192 103 190 108 99 1457 561 2200 5...
result:
ok 1000 numbers