题解:P15007 [UOI 2019 II Stage] 草坪
题目大意
有一段长为
题目分析
step 1
正常来讲,每次剪掉
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n,k;
cin >> n >> k;
if (n % k == 0) cout << n / k;
else cout << n / k + 1;
return 0;
}
发现WA了
step 2
后来我想到,当
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n,k;
cin >> n >> k;
if (k * 2 > n) cout << 3;
else if (n % k == 0) cout << n / k;
else cout << n / k + 1;
return 0;
}
发现WA了
step 3
我又想到,当
最终,我耗时
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n,k;
cin >> n >> k;
if (k * 2 > n and k != n) cout << 3;
else if (n % k == 0) cout << n / k;
else cout << n / k + 1;
return 0;
}