QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246740#5152. Circular Caramel Cookiethanhchauns2WA 1ms3884kbC++173.1kb2023-11-11 03:08:302023-11-11 03:08:31

Judging History

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

  • [2023-11-11 03:08:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2023-11-11 03:08:30]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define rd read()
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define p pair
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
namespace {
	typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll;
//	istream& operator>>(istream& i, ll &v){ long long t; i >> t; v = t;	return i;}
//	ostream& operator<<(ostream& out, ll &v){ 
//		vector<long long> x; ll u = v; 
//		while(u){x.pb(u % 10); u /= 10;} 
//		reverse(x.begin(), x.end()); 
//		for (auto &o : x){out << o;} return out;
//	}
	ll read(){ ll x; cin >> x; return x; } ld PI = 3.14159265358979323846; ld eps = 1e-6; ll mod = 1e9 + 7;
	template<typename T> void Unique(T &a) {a.erase(unique(a.begin(), a.end()), a.end());}
	template<typename T1, typename T2> ostream& operator<<(ostream& out, const p<T1, T2>& x) {return out << x.f << ' ' << x.s;}
	template<typename T1, typename T2> istream& operator>>(istream& in, p<T1, T2>& x) {return in >> x.f >> x.s;}
	template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
	template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for(auto &x : a) out << x << ' '; return out;};
	template<typename T> istream& operator>>(istream& in, deque<T>& a) {for(auto &x : a) in >> x; return in;};
	template<typename T> ostream& operator<<(ostream& out, deque<T>& a) {for(auto &x : a) out << x << ' '; return out;};
	template<typename T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
	template<typename T> using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;
	template<typename T> using pq = priority_queue<T>; template<typename T> using reverse_pq = priority_queue<T, vector<T>, greater<T> >;
	template<typename T> using matrix = vector<vector<T> >; template<typename T> using rubik = vector<vector<vector<T> > >;
	vector<ll> rdv(int sz) { vector<ll> x(sz); cin >> x;return x; }
	mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
	const int N = 500 + 5;
} // main template

ll calc(ld r){
	ll r2 = r; ld r3 = r2; ll h = r2 - 1;
	if (r3 < r){
		h = r2;
	}
	ll c = sqrt(r * r - h * h);
	if (c == 0){
		h--;
		c = sqrt(r * r - h * h);
	}
	ll area1 = h * c * 4;
	
	ll area2 = h * (h - 1) / 2;
	area2 -= c * (c - 1) / 2;
	
	return area1 + area2 * 4;
}

void solve(){
	ll x = rd + 1; ld l = 1, r = 1e9, ans = 0;
	for (int i = 0; i <= 400; i++){
		ld mid = (l + r) / 2;
		ll y = calc(mid);
		if (y >= x){
			ans = mid;
			r = mid;
		} else {
			l = mid;
		}
//		cout << l << ' ' << r << ' ' << mid << '\n';
	}
	cout << fixed << setprecision(20) << ans << '\n';
}

signed main(){
    cin.tie(0) -> ios::sync_with_stdio(false);
	for (int i = 1, j = 1; i > 0; i--, j++) {
		solve();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3680kb

input:

11

output:

2.23606797749978969641

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #2:

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

input:

59

output:

5.00000000000000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #3:

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

input:

1

output:

1.41421356237309504887

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #4:

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

input:

2

output:

1.41421356237309504887

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #5:

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

input:

3

output:

1.41421356237309504887

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #6:

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

input:

4

output:

2.23606797749978969641

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #7:

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

input:

1000000000

output:

22172.82266649873335495613

result:

wrong answer 1st numbers differ - expected: '17841.8813190', found: '22172.8226665', error = '0.2427402'