Skip to content

Commit cce754f

Browse files
committed
icpc practice
1 parent edff7fa commit cce754f

File tree

2 files changed

+52
-0
lines changed
  • acm-icpc/Regional/South Korea/2018/Qualification

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
typedef long long ll;
6+
7+
static ll n;
8+
9+
int main()
10+
{
11+
cin >> n;
12+
13+
int start = 1;
14+
while(true)
15+
{
16+
ll sum = start + (start + 1) * ((1LL << (start + 1)) - 1);
17+
18+
if(n <= sum) break;
19+
start++;
20+
}
21+
22+
cout << start << '\n';
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
static int a, b, n, w;
6+
7+
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
8+
9+
int main()
10+
{
11+
cin >> a >> b >> n >> w;
12+
int x, y, ans[2] = { 0, 0 };
13+
14+
for(x = 1, y = n - 1; x < n; x++, y--)
15+
{
16+
if(a * x + b * y == w)
17+
{
18+
if(ans[0] == 0) ans[0] = x, ans[1] = y;
19+
else
20+
{
21+
cout << -1 << '\n';
22+
return 0;
23+
}
24+
}
25+
}
26+
27+
if(ans[0]) cout << ans[0] << ' ' << ans[1] << '\n';
28+
else cout << -1 << '\n';
29+
}

0 commit comments

Comments
 (0)