QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65614#5149. Best Carry Player18067989237WA 25ms5500kbC++141.7kb2022-12-02 13:53:472022-12-02 13:53:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-02 13:53:49]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:5500kb
  • [2022-12-02 13:53:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define ll long long
#define fi first
#define se second
#define int long long
#define no "NO\n"
#define yes "YES\n"
#define pb push_back
#define endl "\n"
#define dbg(x...) do{cout<<#x<<" -> ";err(x);}while (0)
void err() { cout << '\n'; }

template<class T, class... Ts>
void err(T arg, Ts... args) {
    cout << arg << ' ';
    err(args...);
}

const int N = 5e5 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
int a[N],b[N],c[N],cnt;
string cal(string A, string B){
     int len = max(A.size(), B.size());
     for (int i = A.size() - 1, j = 1; i >= 0; i--, j++)
         a[j] = A[i] - '0';
     for (int i = B.size() - 1, j = 1; i >= 0; i--, j++)
         b[j] = B[i] - '0';
     for(int i=1;i<=len;i++) c[i]=0;
     for (int i = 1; i <= len; i++) {
         c[i] += a[i] + b[i];
         c[i + 1] = c[i] / 10;
         if(c[i+1]) cnt++;
         c[i] %= 10;
     }
     if (c[len + 1]) len++;
     string x;
     for (int i = len; i >= 1; i--)
         x+= (c[i]+'0');
     return x;
}
int e[N];
void  solve(){
	  int n;
	  cin >> n;
	  string s,sum;
	  for(int i=1;i<=n;i++){
	  	cin >> e[i];
	  }
	  sort(e+1,e+1+n);
	  sum = to_string(e[1]);
	  cnt=0;
	  for(int i=2;i<=n;i++){
        s = to_string(e[i]);
	  	sum = cal(sum,s);
	  }
	  cout << cnt << endl;
	  
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr),cout.tie(nullptr);
  	int T=1;
  	cin >>T;
  	while(T--) solve();
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5500kb

input:

2
3
9 99 999
1
12345

output:

5
0

result:

ok 2 number(s): "5 0"

Test #2:

score: 0
Accepted
time: 25ms
memory: 5332kb

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: -100
Wrong Answer
time: 17ms
memory: 5424kb

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
42
42
38
38
41
39
39
38
42
38
42
39
42
42
40
40
45
35
41
38
41
41
41
40
35
50
39
43
33
45
43
46
41
36
42
40
41
40
38
34
44
40
44
38
40
41
36
36
45
37
39
40
41
43
46
41
43
40
42
38
41
38
43
41
40
42
42
41
40
38
41
36
43
41
40
44
35
37
44
40
36
36
43
41
41
43
45
32
38
...

result:

wrong answer 12th numbers differ - expected: '40', found: '42'