QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#134381 | #2290. Kinking Cables | PetroTarnavskyi# | RE | 0ms | 0kb | C++17 | 1.7kb | 2023-08-03 18:36:12 | 2023-08-03 18:36:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;
vector<pair<db, db>> ans;
const db eps = 1e-6;
int main()
{
int n, m;
db l;
cin >> n >> m >> l;
db sta = l;
ans.PB(MP(n, m));
while(true){
assert(l >= sqrt(n * n + m * m) - eps);
if(l <= n + m){
db L = 0, R = m;
FOR(t, 0, 300){
db x = (L + R) / 2;
db val = (m - x) + sqrt(x * x + n * n);
if(val > l)
L = x;
else
R = x;
}
ans.PB(MP(n, R));
ans.PB(MP(0, 0));
break;
}
l -= m + 1;
ans.PB(MP(n, 0));
ans.PB(MP(n - 1, 0));
n--;
if(l <= m + sqrt(n * n + m * m)){
db L = 0, R = m;
FOR(t, 0, 300){
db x = (L + R) / 2;
db val = x + sqrt(x * x + n * n);
if(val > l)
R = x;
else
L = x;
}
ans.PB(MP(n, R));
ans.PB(MP(0, 0));
break;
}
ans.PB(MP(n, m));
ans.PB(MP(n - 1, m));
n--;
assert(n >= 0);
}
db cur = 0;
FOR(i, 0, SZ(ans) - 1){
db x = ans[i].F - ans[i + 1].F;
db y = ans[i].S - ans[i + 1].S;
cur += sqrt(x * x + y * y);
}
//cerr << sta << " " << cur << endl;
assert(abs(sta - cur) < eps);
cout << SZ(ans) << endl;
reverse(ALL(ans));
cout << fixed << setprecision(8);
FOR(i, 0, SZ(ans))
cout << ans[i].F << " " << ans[i].S << endl;
return 0;
}
詳細信息
Test #1:
score: 0
Dangerous Syscalls
input:
79 78 1980.7712136406