結果
| 問題 | No.1059 素敵な集合 |
| コンテスト | |
| ユーザー |
k82b
|
| 提出日時 | 2025-08-27 19:21:39 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 131 ms / 2,000 ms |
| + 93µs | |
| コード長 | 471 bytes |
| 記録 | |
| コンパイル時間 | 1,313 ms |
| コンパイル使用メモリ | 225,420 KB |
| 実行使用メモリ | 52,708 KB |
| 最終ジャッジ日時 | 2026-07-14 12:12:46 |
| 合計ジャッジ時間 | 3,357 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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