QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572871 | #3941. Joint Attack | LaVuna47# | AC ✓ | 1ms | 3840kb | C++17 | 2.0kb | 2024-09-18 16:38:14 | 2024-09-18 16:38:15 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
pll add(pll a, pll b)
{
ll up = a.x*b.y + b.x*a.y;
ll down = a.y * b.y;
ll g = gcd(up, down);
up /= g;
down /= g;
return {up, down};
}
int solve()
{
ll n;
if(!(cin >> n))
return 1;
vector<ll> x(n);
FOR(i, n) cin >> x[i];
pll num = {1, x[n-1]};
for(int i = n-2; i >= 0; --i)
{
num = add(num, {x[i], 1ll});
swap(num.x, num.y);
}
swap(num.x, num.y);
cout << num.x << '/' << num.y << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3680kb
input:
2 2 3
output:
7/3
result:
ok single line: '7/3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
4 1 1 1 1
output:
5/3
result:
ok single line: '5/3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
31 2 1 1 2 1 1 4 1 1 6 1 1 8 1 1 10 1 1 12 1 1 14 1 1 16 1 1 18 1 1 20
output:
36765228701422/14239179076871
result:
ok single line: '36765228701422/14239179076871'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
9 99 98 97 96 95 94 93 92 91
output:
628714475514709915/6349996832762901
result:
ok single line: '628714475514709915/6349996832762901'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
40 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:
165580141/102334155
result:
ok single line: '165580141/102334155'