Skip to content

Instantly share code, notes, and snippets.

@ctylim
Created September 2, 2015 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctylim/f8f6d6d82999900a0b46 to your computer and use it in GitHub Desktop.
Save ctylim/f8f6d6d82999900a0b46 to your computer and use it in GitHub Desktop.
yukicoder No.23
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define NUM 10001
typedef long long ll;
using namespace std;
int inputValue(){
int a;
cin >> a;
return a;
};
void inputArray(int * p, int a){
rep(i, a){
cin >> p[i];
}
};
void inputVector(vector<int> * p, int a){
rep(i, a){
int input;
cin >> input;
p -> push_back(input);
}
}
template <typename T>
void output(T a, int precision) {
if(precision > 0){
cout << setprecision(precision) << a << "\n";
}
else{
cout << a << "\n";
}
}
float dp[NUM] = {0};
int main(int argc, const char * argv[]) {
// source code
int H = inputValue();
int A = inputValue();
int D = inputValue();
dp[0] = 1;
if(A >= D){
output((int)(H / A) + 1, 0);
}
else{
repd(i, 1, A + 1){
dp[i] = 1.0;
}
repd(i, A + 1, D + 1){
dp[i] = 1.5;
}
repd(i, D + 1, NUM){
dp[i] = min(dp[i - A] + 1.0, dp[i - D] + 1.5);
}
output(dp[H], 0);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment