Why is the solution working well on vscode, but not even compiling in codeforces. Earning on bets

Revision en1, by Darkrai3112, 2024-06-20 17:26:37

https://mirror.codeforces.com/contest/1979/problem/C

https://mirror.codeforces.com/contest/1979/submission/266588454

include <bits/stdc++.h>

using namespace std;

define M 1e9+7

define pb push_back

define int long long int

define push push_back

define pop pop_back

define yes cout << "yes" << endl

define no cout << "no" << endl

define all(v) v.begin(),v.end()

define rall(v) v.rbegin(),v.rend()

define vsort(v) sort(all(v))

define vrsort(v) sort(rall(v))

define vreverse(v) reverse(all(v))

define vmin(v) *min_element(all(v));

define vmax(v) *max_element(all(v));

define vmini(v) min_element(all(v)) — v.begin()

define vmaxi(v) max_element(all(v)) — v.begin()

//#define vsum(v) accumulate(all(v), 0 * 1LL) //For descending just change the sign bool comp1(pair<int,int> p1,pair<int,int> p2){ return p1.first<p2.first; } bool comp2(pair<int,int> p1,pair<int,int> p2){ return p1.second<p2.second; }

template std::istream &operator>>(std::istream &in, std::vector &v){ for (int i = 0; i < v.size(); i++){ in >> v[i]; } return in; }

template ostream &operator<<(ostream &os, const vector &v){ for (int i = 0; i < v.size(); ++i){ os << v[i] << ' '; } os << endl; return os; }

// Function to calculate GCD of two numbers int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a; }

// Function to calculate LCM of two numbers int lcm(int a, int b) { return std::abs(a * b) / gcd(a, b); }

void solve(){ int n; cin>>n; vectorarr(n); cin>>arr; int lccm = accumulate(arr.begin(), arr.end(), 1, lcm); // for(int i=0;i<n;i++) // { // if(lccm==arr[i]) // { // cout<<-1<<endl; // return; // } // } int sol=0; for(int i=0;i<n;i++) { sol+=lccm/arr[i]; } if(sol==lccm) { cout<<-1<<endl; return; } for(int i=0;i<n;i++) { cout<<lccm/arr[i]<<" ";

} cout<<endl;

}

signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t=1; cin >> t; while(t--){ solve(); //solve() ? yes : no; } } /*// Function to calculate GCD of two numbers int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a; }

// Function to calculate LCM of two numbers int lcm(int a, int b) { return std::abs(a * b) / gcd(a, b); }

int main() { std::vector nums = {12, 18, 24, 36};

// Using std::accumulate and custom lcm function to find the LCM of the vector
int result = accumulate(nums.begin(), nums.end(), 1, lcm);

cout << "LCM of the vector is " << result << endl;

return 0;

} */

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Darkrai3112 2024-06-20 17:34:39 2738
en1 English Darkrai3112 2024-06-20 17:26:37 2948 Initial revision (published)