結果
| 問題 |
No.1611 Minimum Multiple with Double Divisors
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-21 23:54:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,106 bytes |
| コンパイル時間 | 739 ms |
| コンパイル使用メモリ | 78,360 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-17 20:47:43 |
| 合計ジャッジ時間 | 6,650 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 28 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define ll long long
using namespace std;
const int maxn=1000;
ll vis[maxn];
vector<ll> prime;
void init(){
for(int i=2;i<maxn;i++){
if(vis[i]==0) {
prime.push_back(i);
for(int j=i;j<maxn;j+=i){
vis[j]=i;
}
}
}
}
bool check(ll i,ll x){
if(x%i==0) return false;
set<ll> s;
while(i!=1){
s.insert(vis[i]);
i/=vis[i];
}
s.insert(i);
for(int j:s){
if(x%j!=0)return false;
}
return true;
}
int main(){
ios::sync_with_stdio(false);
int T;cin>>T;
init();
while(T--){
ll X;cin>>X;
ll p=-1;
for(ll i:prime){
if(X%i!=0){
p=i;
break;
}
}
ll ans=p*X;
for(ll i=p-1;i>=2;i--){
//i 是一个合数,i可以被X的因子表示,但是i不能被X整除。
if(check(i,X)){
ans=i*X;
}
}
cout<<ans<<endl;
}
return 0;
}