提出 #64409852
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
int M,K;cin>>M>>K;
vector<int> N(M,0), P(0);
for(int i=1;i<M;i++){
N.at(i)=i+1;
}
for(int i=1;i<(int)sqrt(M);i++){
if(N.at(i)){
for(int j=2;j<=M/N.at(i);j++){
N.at(j*N.at(i)-1)=0;
}
}
}
for(int i=0;i<M;i++){
if(N.at(i)) P.push_back(N.at(i));
}
vector<int> G(1,1);
vector<int> L(P.size(),K-1);
for(int i=0;i<P.size();i++){
int A=1;
for(int j=0;j<K;j++){
A*=P.at(i);
if(A<=M){
G.push_back(A);
L.at(i)--;
}else{
break;
}
}
}
int l=0,r=P.size()-1;
while(1){
while(l<L.size()&&!L.at(l)) l++;
while(0<=r&&!L.at(r)) r--;
if(r<=l) break;
if(P.at(l)*P.at(r)<=M){
G.push_back(P.at(l)*P.at(r));
L.at(r)--;
L.at(l)--;
r--;
}else{
r--;
if(r<=l) break;
}
}
cout<<G.size()<<endl;
for(int i=0;i<G.size();i++){
cout<<G.at(i)<<" ";
}
cout<<endl;
}
提出情報
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:24:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
24 | for(int i=0;i<P.size();i++){
| ~^~~~~~~~~
Main.cpp:39:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
39 | while(l<L.size()&&!L.at(l)) l++;
| ~^~~~~~~~~
Main.cpp:54:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
54 | for(int i=0;i<G.size();i++){
| ~^~~~~~~~~
ジャッジ結果
| セット名 | Sample | K2 | K3 | K4 | K5 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 10 | 0 / 20 | 0 / 30 | 0 / 40 | ||||||||||||||||||
| 結果 |
|
|
|
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt |
| K2 | 01_random_2_00.txt, 01_random_2_01.txt, 01_random_2_02.txt, 01_random_2_03.txt, 01_random_2_04.txt, 02_hand_2_00.txt, 02_hand_2_01.txt, 02_hand_2_02.txt, 02_hand_2_03.txt |
| K3 | 03_random_3_00.txt, 03_random_3_01.txt, 03_random_3_02.txt, 03_random_3_03.txt, 03_random_3_04.txt, 04_hand_3_00.txt, 04_hand_3_01.txt, 04_hand_3_02.txt, 04_hand_3_03.txt |
| K4 | 05_random_4_00.txt, 05_random_4_01.txt, 05_random_4_02.txt, 05_random_4_03.txt, 05_random_4_04.txt, 06_hand_4_00.txt, 06_hand_4_01.txt, 06_hand_4_02.txt, 06_hand_4_03.txt |
| K5 | 00_sample_00.txt, 07_random_5_00.txt, 07_random_5_01.txt, 07_random_5_02.txt, 07_random_5_03.txt, 07_random_5_04.txt, 08_hand_5_00.txt, 08_hand_5_01.txt, 08_hand_5_02.txt, 08_hand_5_03.txt, 08_hand_5_04.txt, 08_hand_5_05.txt, 08_hand_5_06.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3400 KiB |
| 01_random_2_00.txt | WA | 2 ms | 3792 KiB |
| 01_random_2_01.txt | WA | 3 ms | 3960 KiB |
| 01_random_2_02.txt | WA | 2 ms | 3536 KiB |
| 01_random_2_03.txt | WA | 4 ms | 4292 KiB |
| 01_random_2_04.txt | WA | 2 ms | 3560 KiB |
| 02_hand_2_00.txt | AC | 1 ms | 3680 KiB |
| 02_hand_2_01.txt | WA | 1 ms | 3632 KiB |
| 02_hand_2_02.txt | WA | 1 ms | 3696 KiB |
| 02_hand_2_03.txt | WA | 4 ms | 4436 KiB |
| 03_random_3_00.txt | WA | 3 ms | 3840 KiB |
| 03_random_3_01.txt | WA | 4 ms | 4100 KiB |
| 03_random_3_02.txt | WA | 5 ms | 4476 KiB |
| 03_random_3_03.txt | WA | 3 ms | 4032 KiB |
| 03_random_3_04.txt | WA | 2 ms | 3588 KiB |
| 04_hand_3_00.txt | AC | 1 ms | 3660 KiB |
| 04_hand_3_01.txt | WA | 1 ms | 3484 KiB |
| 04_hand_3_02.txt | WA | 1 ms | 3668 KiB |
| 04_hand_3_03.txt | WA | 6 ms | 4532 KiB |
| 05_random_4_00.txt | WA | 1 ms | 3596 KiB |
| 05_random_4_01.txt | WA | 3 ms | 3892 KiB |
| 05_random_4_02.txt | WA | 5 ms | 4280 KiB |
| 05_random_4_03.txt | WA | 1 ms | 3552 KiB |
| 05_random_4_04.txt | WA | 5 ms | 4376 KiB |
| 06_hand_4_00.txt | AC | 1 ms | 3516 KiB |
| 06_hand_4_01.txt | WA | 2 ms | 3824 KiB |
| 06_hand_4_02.txt | WA | 1 ms | 3776 KiB |
| 06_hand_4_03.txt | WA | 1 ms | 3620 KiB |
| 07_random_5_00.txt | WA | 3 ms | 3940 KiB |
| 07_random_5_01.txt | WA | 2 ms | 3724 KiB |
| 07_random_5_02.txt | WA | 4 ms | 4164 KiB |
| 07_random_5_03.txt | WA | 3 ms | 3980 KiB |
| 07_random_5_04.txt | WA | 3 ms | 3780 KiB |
| 08_hand_5_00.txt | AC | 1 ms | 3620 KiB |
| 08_hand_5_01.txt | WA | 1 ms | 3792 KiB |
| 08_hand_5_02.txt | WA | 5 ms | 4416 KiB |
| 08_hand_5_03.txt | WA | 1 ms | 3572 KiB |
| 08_hand_5_04.txt | WA | 1 ms | 3584 KiB |
| 08_hand_5_05.txt | AC | 1 ms | 3680 KiB |
| 08_hand_5_06.txt | AC | 1 ms | 3680 KiB |