QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#821955#9061. Streets BehindWeaRD276#WA 0ms3928kbC++201.6kb2024-12-19 19:46:292024-12-19 19:46:32

Judging History

你现在查看的是最新测评结果

  • [2024-12-19 19:46:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3928kb
  • [2024-12-19 19:46:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double db;
//typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;


int solve()
{
	ll n, k, a, b;
	if (!(cin >> n >> k >> a >> b))
		return 1;
	
	if (n * (b - a) < a)
	{
		cout << "-1\n";
		return 0;
	}
	
	auto check = [&](ll tr) -> bool
	{
		db dr = pow((b * 1. / a), tr);
		//ll cil = floor(dr);
		return n * 1. * dr >= n + k;
	};
	
	ll l = 0, r = 1e9 + 47;
	while (r - l > 1)
	{
		ll mid = (l + r) / 2;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << '\n';
	
	//int ans = 0;
	//while (k)
	//{
		//ans++;
		//ll y = (n * (b - a)) / a;
		////cerr << "y = " << y << '\n';
		//if (y == 0)
		//{
			//cout << "-1\n";
			//return 0;
		//}
		////y = abs(y);
		//k -= y;
		//n += y;
		//k = max(0LL, k);
	//}
	
	//cout << ans << '\n';
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3920kb

input:

3
9 5 5 6
2 7 1 8
3 4 1 5

output:

3
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

54
1 1 1 1
1 1 1 2
1 1 1 3
1 1 2 2
1 1 2 3
1 1 3 3
1 2 1 1
1 2 1 2
1 2 1 3
1 2 2 2
1 2 2 3
1 2 3 3
1 3 1 1
1 3 1 2
1 3 1 3
1 3 2 2
1 3 2 3
1 3 3 3
2 1 1 1
2 1 1 2
2 1 1 3
2 1 2 2
2 1 2 3
2 1 3 3
2 2 1 1
2 2 1 2
2 2 1 3
2 2 2 2
2 2 2 3
2 2 3 3
2 3 1 1
2 3 1 2
2 3 1 3
2 3 2 2
2 3 2 3
2 3 3 3
3 1 1 1
3...

output:

-1
1
1
-1
-1
-1
-1
2
1
-1
-1
-1
-1
2
2
-1
-1
-1
-1
1
1
-1
1
-1
-1
1
1
-1
2
-1
-1
2
1
-1
3
-1
-1
1
1
-1
1
-1
-1
1
1
-1
2
-1
-1
1
1
-1
2
-1

result:

ok 54 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3928kb

input:

54
10 10 10 10
10 10 10 11
10 10 10 12
10 10 11 11
10 10 11 12
10 10 12 12
10 11 10 10
10 11 10 11
10 11 10 12
10 11 11 11
10 11 11 12
10 11 12 12
10 12 10 10
10 12 10 11
10 12 10 12
10 12 11 11
10 12 11 12
10 12 12 12
11 10 10 10
11 10 10 11
11 10 10 12
11 10 11 11
11 10 11 12
11 10 12 12
11 11 10 ...

output:

-1
8
4
-1
-1
-1
-1
8
5
-1
-1
-1
-1
9
5
-1
-1
-1
-1
7
4
-1
8
-1
-1
8
4
-1
8
-1
-1
8
5
-1
9
-1
-1
7
4
-1
7
-1
-1
7
4
-1
8
-1
-1
8
4
-1
8
-1

result:

wrong answer 2nd lines differ - expected: '10', found: '8'