传送门:CF
AC code:
/*
adrui's submission
Language : C++
Result : Accepted
Favorite : Dragon Balls
Love : yy
Motto : Choose & Quit
Standing in the Hall of Fame
*/
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn(100005);
long long n, a, b, c;
#define debug 0
#define lowbit(x) (x & (-x))
#define M(a, b) memset(a, b, sizeof(a))
int main() {
#if debug
freopen("in.txt", "r", stdin);
#endif //debug
cin.tie(0);
cin.sync_with_stdio(false);
while (cin >> n >> a >> b >> c) {//枚举
long long ans;
n %= 4;
if (n == 0) ans = 0;
else {
if (n == 1) ans = min(3 * a, min(c, a + b));
else if (n == 2) ans = min(b, 2 * min(a, c));
else ans = min(3 * c, min(a, b + c));
}
cout << ans << endl;
}
return 0;
}