Submission #13782589


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define double long double
int a[100005];
int inf = 1e18;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ans = 1, n, x;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0;
            exit(0);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (ans > inf / (double)a[i]) {
            cout << -1;
            exit(0);
        }
        ans *= a[i];
    }
    cout << ans << '\n';
    return 0;
}

Submission Info

Submission Time
Task B - Multiplication 2
User traktor74
Language C++ (GCC 9.2.1)
Score 200
Code Size 682 Byte
Status AC
Exec Time 23 ms
Memory 4424 KB

Compile Error

./Main.cpp:10:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   10 | main() {
      |      ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:21: warning: unused variable ‘x’ [-Wunused-variable]
   17 |     int ans = 1, n, x;
      |                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, small11_02.txt, small11_03.txt, small11_04.txt, small12_02.txt, small12_03.txt, small12_04.txt, small21_01.txt, small21_02.txt, small21_03.txt, small22_01.txt, small22_02.txt, small22_03.txt, zero_01.txt, zero_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 2 ms 3468 KB
hand_02.txt AC 2 ms 3568 KB
max_01.txt AC 23 ms 4324 KB
max_02.txt AC 11 ms 4384 KB
random_01.txt AC 16 ms 4112 KB
random_02.txt AC 12 ms 3892 KB
random_03.txt AC 12 ms 4024 KB
sample_01.txt AC 2 ms 3524 KB
sample_02.txt AC 2 ms 3648 KB
sample_03.txt AC 2 ms 3608 KB
small11_02.txt AC 3 ms 3536 KB
small11_03.txt AC 2 ms 3484 KB
small11_04.txt AC 2 ms 3536 KB
small12_02.txt AC 2 ms 3540 KB
small12_03.txt AC 2 ms 3540 KB
small12_04.txt AC 2 ms 3536 KB
small21_01.txt AC 6 ms 4380 KB
small21_02.txt AC 11 ms 4424 KB
small21_03.txt AC 10 ms 4272 KB
small22_01.txt AC 11 ms 4324 KB
small22_02.txt AC 14 ms 4368 KB
small22_03.txt AC 10 ms 4392 KB
zero_01.txt AC 14 ms 3872 KB
zero_02.txt AC 13 ms 3864 KB