結果
| 問題 |
No.1059 素敵な集合
|
| コンテスト | |
| ユーザー |
k82b
|
| 提出日時 | 2025-08-27 19:21:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 179 ms / 2,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 2,490 ms |
| コンパイル使用メモリ | 209,176 KB |
| 実行使用メモリ | 53,416 KB |
| 最終ジャッジ日時 | 2025-08-27 19:21:43 |
| 合計ジャッジ時間 | 4,092 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/dsu>
void summon()
{
int L,R; cin>>L>>R;
vector<tuple<int,int,int>> edges;
for(int i=L; i<R; ++i) edges.push_back({1,i,i+1});
for(int i=L; i<R; ++i)
for(int j=i+i; j<=R; j+=i)
edges.push_back({0,i,j});
sort(edges.begin(),edges.end());
int ans=0;
atcoder::dsu uf(R+1);
for(auto[w,u,v]:edges)
if(!uf.same(u,v))
{
uf.merge(u,v);
ans+=w;
}
cout<<ans<<"\n";
}
int main()
{
summon();
}
k82b