Algorithm-Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub UScuber/Algorithm-Library

:heavy_check_mark: test/aoj/NTL/NTL_1_C.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/NTL_1_C"

#include "../../../template/template.hpp"

#include "../../../math/gcdlcm.hpp"

int main(){
  int n;
  cin >> n;
  int ans = 1;
  rep(i, n){
    int a; cin >> a;
    ans = lcm(ans, a);
  }
  cout << ans << "\n";
}
#line 1 "test/aoj/NTL/NTL_1_C.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/NTL_1_C"

#line 1 "template/template.hpp"
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#include <climits>
#include <functional>
#include <cassert>
#include <numeric>
#include <cstring>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define per(i, n) for(int i = (n) - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
constexpr int mod = 1000000007;
using namespace std;
template<class T, class U>
bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; }
template<class T, class U>
bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; }
#line 4 "test/aoj/NTL/NTL_1_C.test.cpp"

#line 1 "math/gcdlcm.hpp"
template<class T>
T gcd(T a, T b){
  if(!b) return a;
  return gcd(b, a % b);
}

template<class T>
T lcm(T a, T b){
  return a / gcd(a, b) * b;
}
#line 6 "test/aoj/NTL/NTL_1_C.test.cpp"

int main(){
  int n;
  cin >> n;
  int ans = 1;
  rep(i, n){
    int a; cin >> a;
    ans = lcm(ans, a);
  }
  cout << ans << "\n";
}
Back to top page