結果
| 問題 | No.3663 LCM Decomposition |
| コンテスト | |
| ユーザー |
👑 kmjp
|
| 提出日時 | 2026-09-02 00:21:41 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,962 bytes |
| 記録 | |
| コンパイル時間 | 1,605 ms |
| コンパイル使用メモリ | 228,940 KB |
| 実行使用メモリ | 9,800 KB |
| 最終ジャッジ日時 | 2026-09-02 00:22:20 |
| 合計ジャッジ時間 | 3,816 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------
int T;
ll N,L,R;
vector<int> cand[1<<9];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>T;
while(T--) {
int mask;
FOR(mask,1<<9) cand[mask].clear();
cin>>N>>L>>R;
vector<int> V;
for(i=1;i*i<=N;i++) if(N%i==0) {
V.push_back(i);
if(i*i!=N) V.push_back(N/i);
}
map<int,int> M;
y=N;
for(x=2;x*x<=y;x++) if(y%x==0) {
M[x]=1;
while(y%x==0) {
M[x]*=x;
y/=x;
}
}
if(y>1) M[y]=y;
vector<int> D;
FORR2(a,b,M) D.push_back(b);
int ND=D.size();
FORR(v,V) {
mask=0;
FOR(i,ND) if(v%D[i]==0) mask|=1<<i;
cand[mask].push_back(v);
}
FOR(i,ND) {
FOR(mask,1<<ND) {
if(mask&(1<<i)) {
FORR(a,cand[mask]) cand[mask^(1<<i)].push_back(a);
}
if(cand[mask].size()>3) cand[mask].resize(3);
}
}
vector<int> ret;
FOR(mask,1<<ND) if(ret.empty()) {
int ma=(1<<ND)-1-mask;
for(int sm=mask;sm>=0;sm--) if(ret.empty()) {
sm=sm&mask;
int sm2=mask^sm;
FORR(a,cand[ma]) FORR(b,cand[sm]) FORR(c,cand[sm2]) {
if(a!=b&&a!=c&&b!=c) ret={a,b,c};
}
}
}
sort(ALL(ret));
if(ret.empty()) cout<<-1<<endl;
else cout<<ret[0]<<" "<<ret[1]<<" "<<ret[2]<<endl;
}
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
kmjp