mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 02:18:48 +00:00
P2036 [COCI2008-2009#2] PERKET
R52228829
This commit is contained in:
parent
c0cc097c32
commit
7d450ae7c6
28
Luogu/problem/P2036/P2036.cpp
Normal file
28
Luogu/problem/P2036/P2036.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct {
|
||||
int s, b;
|
||||
} a[15];
|
||||
int n, ans = 0x3f3f3f3f;
|
||||
|
||||
void dfs(int now, int s, int b) {
|
||||
if (now > n) {
|
||||
if (s == 1 && b == 0) return;
|
||||
ans = min(abs(s - b), ans);
|
||||
return;
|
||||
}
|
||||
dfs(now + 1, s * a[now].s, b + a[now].b);
|
||||
dfs(now + 1, s, b);
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].s >> a[i].b;
|
||||
}
|
||||
dfs(1, 1, 0);
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user