QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#690127 | #5149. Best Carry Player | IsacBieber# | AC ✓ | 18ms | 5848kb | C++23 | 1.4kb | 2024-10-30 20:25:22 | 2024-10-30 20:25:23 |
Judging History
answer
#include <bits/stdc++.h>
// #include<bits/extc++.h>
#define endl '\n'
#define eps 1e-7
#define pb push_back
#define eb emplace_back
#define debug(x) cerr<<#x<<": "<<x<<'\n';
// using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair <ll,ll>;
using pii = pair <int,int>;
using ull = unsigned long long;
const int N = 1e6 + 5, M = 50, MOD = 1e9 + 7;
mt19937_64 rnd (chrono::steady_clock::now().time_since_epoch().count());
int n, ans, a[N], cal[M], tmp[M];
void isac()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=20;i++) cal[i] = 0;
ans = 0;
for(int i=1;i<=n;i++)
{
int len = 0;
int x = a[i];
for(int j=1;j<=20;j++) tmp[j] = 0;
while(x)
{
tmp[++len] = x%10;
x /= 10;
}
int carry = 0;
for(int j=1;j<=20;j++)
{
int s = tmp[j] + cal[j] + carry;
cal[j] = s%10;
carry = s/10;
if(carry) ans ++;
}
}
cout<<ans<<'\n';
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while (T--) isac();
return 0;
}
/*
Zena youth together.
Such a pretty name.
There will be a long story.
Time will tell all.
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
2 3 9 99 999 1 12345
output:
5 0
result:
ok 2 number(s): "5 0"
Test #2:
score: 0
Accepted
time: 18ms
memory: 3704kb
input:
100000 1 481199252 1 634074578 1 740396295 1 579721198 1 503722503 1 202647942 1 268792718 1 443917727 1 125908043 1 717268783 1 150414369 1 519096230 1 856168102 1 674936674 1 274667941 1 527268921 1 421436316 1 286802932 1 646837311 1 451394766 1 105650419 1 302790137 1 254786900 1 76141081 1 7393...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 16ms
memory: 3732kb
input:
10000 10 598196518 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754 223219513 10 312183499 905549873 673542337 566661387 879397647 434495917 631413076 150918417 579868000 224422012 10 525305826 535526356 404334728 653535984 998133227 879226371 59632864 356493387 62611196...
output:
42 41 42 35 43 35 44 38 39 46 31 40 42 38 38 41 39 39 37 42 38 41 38 42 41 39 40 45 35 41 37 40 41 41 40 35 50 39 42 33 44 43 46 41 35 42 39 41 39 38 34 44 39 43 38 40 41 36 35 45 37 39 40 41 43 44 41 43 40 42 37 41 38 43 40 40 42 42 41 40 37 41 36 42 41 40 44 35 37 43 40 36 36 43 41 41 43 44 32 38 ...
result:
ok 10000 numbers
Test #4:
score: 0
Accepted
time: 12ms
memory: 3588kb
input:
1000 95 708441014 953465932 817091665 611120528 186861396 45214633 309108293 362222948 134971428 346366757 945798520 132315932 293683620 945425590 668726142 893155157 191896353 57521218 112217858 641511394 672365121 156197927 495345729 585777737 567289722 592583094 842472845 908714567 355422360 5153...
output:
421 415 405 417 423 430 439 455 442 423 412 435 435 414 427 426 449 415 421 419 438 436 444 419 417 414 408 412 432 413 420 418 437 433 435 411 428 446 437 412 448 413 435 411 445 441 456 416 395 446 415 405 430 397 448 434 424 401 450 424 402 443 437 411 403 398 426 415 429 435 428 427 426 445 425 ...
result:
ok 1000 numbers
Test #5:
score: 0
Accepted
time: 17ms
memory: 3712kb
input:
100 994 12244197 302751325 391063232 821704902 918351183 911667041 414131481 556158495 532207266 811890152 401118704 474105790 920464458 363136546 386056258 201743030 836389366 341427747 904710546 10486332 810273816 162407523 690627683 544009771 458562152 915779647 609419967 988646785 282973793 7557...
output:
4425 4260 4292 4088 4481 4439 4377 4077 4105 4230 4061 4384 4292 4259 4482 4368 4295 4314 4181 4024 4273 4015 4195 4098 4383 4053 4226 4194 4349 4378 4467 4252 4135 4288 4138 4256 4070 4207 4067 4481 4412 4308 4136 4442 4493 4105 4246 4451 4221 4100 4451 4401 4329 4259 4126 4122 4425 4542 4317 4377 ...
result:
ok 100 numbers
Test #6:
score: 0
Accepted
time: 18ms
memory: 3652kb
input:
10 9581 325436058 136483019 490442151 617394140 868754553 919825920 569669883 288439170 510130318 234741527 76026945 717015345 487315007 875266709 545037960 104367659 262497507 302727188 966353939 868494849 135243336 132447426 740879064 706964765 397609262 760119265 638908162 989468985 296612298 744...
output:
42992 41783 42795 43154 41670 43433 41472 44460 41766 44799
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 18ms
memory: 3912kb
input:
1 91764 529497259 710454586 141218013 789075415 30174257 24849107 468638133 685675008 270621009 839804815 417816804 638763480 610058668 327755609 853625834 43827967 841371333 390187172 335328878 301370841 141452932 622696676 143821498 598237196 720805815 232099091 13807677 211987715 977178764 416876...
output:
412763
result:
ok 1 number(s): "412763"
Test #8:
score: 0
Accepted
time: 12ms
memory: 4036kb
input:
1 99242 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 99...
output:
893169
result:
ok 1 number(s): "893169"
Test #9:
score: 0
Accepted
time: 12ms
memory: 4024kb
input:
1 94967 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...
output:
10548
result:
ok 1 number(s): "10548"
Test #10:
score: 0
Accepted
time: 12ms
memory: 5848kb
input:
1 100000 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 9...
output:
899991
result:
ok 1 number(s): "899991"
Test #11:
score: 0
Accepted
time: 8ms
memory: 4148kb
input:
1 100000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...
output:
11111
result:
ok 1 number(s): "11111"
Test #12:
score: 0
Accepted
time: 8ms
memory: 5684kb
input:
1 100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
11111
result:
ok 1 number(s): "11111"