提出 #22473696
ソースコード 拡げる
// Problem: C - Coprime Set
// Contest: AtCoder - AtCoder Regular Contest 118
// URL: https://atcoder.jp/contests/arc118/tasks/arc118_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a,b,sizeof(a))
#define vi vector<int>
#define vii vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define w(x) int x; cin>>x; while(x--)
#define in(a) for(auto &x: a)cin>>x;
#define out(a) for(auto x: a){cout<<x<<' ';}cout<<'\n';
#define inf 1000000000
//#define mm 1000000007 998244353
void print(bool n){if(n)cout<<"YES";else cout<<"NO";cout<<'\n';}
//spf can be used to prime factorize in O(logn) time
//while usual method takes O(rootn) but requires precomp of O(nloglogn)
/*vector<bool> s;
void sieve(int n){
s.resize(n+1,true);
s[0]=s[1]=false;
//to initialize spf sp[i]=i;
for(int i=2;i*i<=n;i++){
if(s[i]==true){//if(sp[i]==i)
for(int j=i*i;j<=n;j+=i){
s[j]=false;//if(sp[j]==j)sp[j]=i;
}
}
}
}
int N;
vi prime(){
vi a;
rep(i,2,s.size()){
if(s[i])a.pb(i);
if(a.size()==N)return a;
}
}*/
signed main(){
fastio
int N;
cin>>N;
set<int> s;
s.insert(10);
s.insert(15);
bool f=0;
for(int i=6;i<=10000 && !f;i+=6){
s.insert(i);
if(s.size()==N)f=1;
}
for(int i=15;i<=10000 && !f;i+=15){
s.insert(i);
if(s.size()==N)f=1;
}
for(int i=10;i<=10000 && !f;i+=10){
s.insert(i);
if(s.size()==N)f=1;
}
//cout<<s.size()<<'\n';
out(s);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Coprime Set |
| ユーザ | demonhue |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 500 |
| コード長 | 1859 Byte |
| 結果 | AC |
| 実行時間 | 8 ms |
| メモリ | 3712 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:63:14: warning: comparison of integer expressions of different signedness: ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
63 | if(s.size()==N)f=1;
| ~~~~~~~~^~~
./Main.cpp:67:14: warning: comparison of integer expressions of different signedness: ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
67 | if(s.size()==N)f=1;
| ~~~~~~~~^~~
./Main.cpp:71:14: warning: comparison of integer expressions of different signedness: ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
71 | if(s.size()==N)f=1;
| ~~~~~~~~^~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 500 / 500 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 01_sample_01.txt |
| All | 01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_max_01.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01_sample_01.txt | AC | 6 ms | 3516 KiB |
| 02_small_01.txt | AC | 2 ms | 3512 KiB |
| 02_small_02.txt | AC | 2 ms | 3516 KiB |
| 02_small_03.txt | AC | 2 ms | 3648 KiB |
| 02_small_04.txt | AC | 2 ms | 3460 KiB |
| 02_small_05.txt | AC | 3 ms | 3504 KiB |
| 02_small_06.txt | AC | 2 ms | 3660 KiB |
| 02_small_07.txt | AC | 3 ms | 3572 KiB |
| 03_rand_01.txt | AC | 3 ms | 3712 KiB |
| 03_rand_02.txt | AC | 8 ms | 3600 KiB |
| 03_rand_03.txt | AC | 8 ms | 3704 KiB |
| 03_rand_04.txt | AC | 8 ms | 3656 KiB |
| 03_rand_05.txt | AC | 5 ms | 3620 KiB |
| 04_max_01.txt | AC | 8 ms | 3632 KiB |