結果
問題 | No.1611 Minimum Multiple with Double Divisors |
ユーザー |
|
提出日時 | 2021-07-21 23:49:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 310 ms / 2,000 ms |
コード長 | 3,721 bytes |
コンパイル時間 | 1,103 ms |
コンパイル使用メモリ | 132,496 KB |
最終ジャッジ日時 | 2025-01-23 05:19:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 37 |
ソースコード
#include <iostream> #include <algorithm> #include <utility> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <math.h> #include <string.h> #include <iomanip> #include <numeric> #include <cstdlib> #include <cstdint> #include <cmath> #include <functional> #include <limits> #include <cassert> #include <bitset> #include <chrono> #include <random> #include <memory> /* macro */ #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) #define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--) #define Rep(i, a, n) for (i64 i = (i64)(a); i< (i64)(n); i++) #define RRep(i, a, n) for (i64 i = ((i64)(n-i64(1))); i>=(i64)(a); i--) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() /* macro end */ /* template */ namespace ebi { #ifdef LOCAL #define debug(...) \ std::cerr << "LINE: " << __LINE__ << " [" << #__VA_ARGS__ << "]:", \ debug_out(__VA_ARGS__) #else #define debug(...) #endif void debug_out() { std::cerr << std::endl; } template <typename Head, typename... Tail> void debug_out(Head h, Tail... t) { std::cerr << " " << h; if (sizeof...(t) > 0) std::cout << " :"; debug_out(t...); } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) { return os << pa.first << " " << pa.second; } template <typename T> std::ostream& operator<<(std::ostream& os, std::vector<T> vec) { for (std::size_t i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } using size_t = std::size_t; using i64 = long long; using u64 = unsigned long long; template<class T> void fill(std::vector<T> &v) { for(T &e: v) std::cin >> e; } template <class T> inline bool chmin(T &a, T b) { if (a > b){ a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b){ a = b; return true; } return false; } template <class T> T gcd(T a, T b){ if( b==0 ) return a; else return gcd(b, a%b); } template <class T> T lcm(T a, T b) { return (a*b)/gcd(a,b); } template<class T> T Pow(T x, i64 n) { T res = 1; while(n>0){ if(n&1) res = res *x; x = x*x; n>>=1; } return res; } template<class T> T scan() { T val; std::cin >> val; return val; } constexpr i64 LNF = std::numeric_limits<i64>::max()/4; constexpr int INF = std::numeric_limits<int>::max()/4; const long double PI = acos(-1); const std::vector<int> dy = {1,0,-1,0,1,1,-1,-1}; const std::vector<int> dx = {0,1,0,-1,1,-1,1,-1}; } /* template end */ namespace ebi { using ld = long double; using P = std::pair<int,int>; const int p[] = {2,3,5,7,11,13,17,19,23,29,31}; void main_() { i64 x; std::cin >> x; std::vector<int> ret(11,0); i64 y = x; rep(i,0,11) { while(y % p[i] == 0) { y /= p[i]; ret[i]++; } } rep(i,1,32) { int val = i; std::vector<i64> tmp(2,1), l(11,0); rep(j,0,11) { while(val % p[j] == 0) { val /= p[j]; l[j]++; } tmp[0] *= ret[j] + 1; tmp[1] *= ret[j] + l[j] + 1; } if(tmp[0]*2 == tmp[1]) { std::cout << x * i << '\n'; return; } } assert(false); } } int main() { std::cout << std::fixed << std::setprecision(15); std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int t; std::cin >> t; while(t--) { ebi::main_(); } return 0; }