QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#65612 | #5149. Best Carry Player | 18067989237 | TL | 19ms | 9372kb | C++14 | 1.6kb | 2022-12-02 13:48:30 | 2022-12-02 13:48:33 |
Judging History
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';
memset(c,0,sizeof c);
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;
}
void solve(){
int n;
cin >> n;
string s,sum;
cin >> sum;
cnt=0;
for(int i=1;i<n;i++){
cin >> s;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 9372kb
input:
2 3 9 99 999 1 12345
output:
5 0
result:
ok 2 number(s): "5 0"
Test #2:
score: 0
Accepted
time: 19ms
memory: 3360kb
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
Time Limit Exceeded
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...