当前位置:网站首页>TKKC round#3
TKKC round#3
2022-06-24 21:57:00 【Weng Weiqiang】
1. subject :http://xujcoj.org/Home/Problems/status/pro_id/1590
reflection :1. Solving equations -> Bisection approach
2. Pay attention to the judgment of accuracy printf(".1lf",l) Keep one decimal place f:float lf:double .n Retain n Decimal place
3. Encountered a precision problem , Change unity to double, Except to the power
4. It's about mathematics , Equation simplification is generally used
AC Code :
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a, c;
double _exp = 1e-2;
double qp(double x, int y)
{
double ans = 1;
while (y)
{
if (y & 1) { ans = ans * x; }
y >>= 1;
x = x * x;
}
return ans;
}
bool check(double b)
{
double res = 1 - (1.0 / (a + 1));
double q = 1.0 / (b + 1);
res += (q - qp(q, a+1))/ (1 - q);
return res >= c;
}
int main()
{
int T;
cin >> T;
while (T--)
{
cin >> a >> c;
double l = 0, r = 1e9;
while (r - l > _exp)// Within a certain error range
{
double mid = (r + l) / 2;
check(mid) ? l = mid : r = mid;// If you are big, look to the right
}
printf("%.1fl\n", l);// Keep one significant digit
}
}
2. subject :http://xujcoj.org/Home/Problems/status/pro_id/1591/
reflection :
1. And look up the correct way of writing :
ll get(ll x)
{
return x==f[x]?x:f[x]=get(f[x])
}
// If our ancestors are not equal to ourselves Just keep searching
void merge(ll x,ll y)
{
f[get(y)]=get(x);
}
//x Ancestors are equal to y Our ancestors, our ancestors To build a relationship 2.vector When opening an array Set as a global variable
3. Pay attention to determine whether there are duplicate numbers
4.stack flow reason :1. Array too large 2. Dynamic allocation instead , Pile up 3. Recursion into dead loop
AC Code :
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5;
ll f[N + 1];
vector<ll>v1[N + 1];
bool cmp(char x, char y)
{
return x < y;
}
ll get(ll x)
{
return x == f[x] ? x : f[x] = get(f[x]);
}
int main()
{
int T;
cin >> T;
while (T--)
{
for (int i = 0; i <= N; i++)
{
v1[i].clear();
}
for (int i = 0; i <= N; i++)
{
f[i] = i;
}
queue<int>ans;
set<ll>s;
vector<ll>v;
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
ll a, b;
scanf("%lld%lld", &a, &b);
f[get(b)] = get(a);
}
for (int j = 1; j <= n; j++)
{
bool flag = false;
ll x;
scanf("%lld", &x);
int fx = get(x);
if (s.count(fx) == 0)
{
ans.push(fx);
s.insert(fx);
}
v1[fx].push_back(x);
}
bool first = 1;
while (!ans.empty())
{
int t = ans.front();
ans.pop();
for (int i = 0; i < v1[t].size(); i++)
{
if (first)
{
printf("%lld", v1[t][i]);
first = 0;
}
else
{
printf(" %lld", v1[t][i]);
}
}
}
puts("");
}
}
边栏推荐
- Vscode netless environment rapid migration development environment (VIP collection version)
- 心楼:华为运动健康的七年筑造之旅
- Elegant custom ThreadPoolExecutor thread pool
- 2022国际女性工程师日:戴森设计大奖彰显女性设计实力
- [notes of Wu Enda] multivariable linear regression
- 机器学习:线性回归
- Direct attack on "three summers" production: good harvest news spreads frequently and summer broadcasting is in full swing
- Multithreaded finalization
- The most important thing at present
- 煮茶论英雄!福建省发改委、市营商办领导一行莅临育润大健康事业部交流指导
猜你喜欢

Installing Oracle without graphical interface in virtual machine centos7 (nanny level installation)

好想送对象一束花呀

Datakit 代理实现局域网数据统一汇聚

A deep learning model for urban traffic flow prediction with traffic events mined from twitter

Sslhandshakeexception: no subject alternative names present - sslhandshakeexception: no subject alternative names present

EasyBypass
![在每个树行中找最大值[分层遍历之一的扩展]](/img/5b/81ff20b61c0719ceb6873e44878859.png)
在每个树行中找最大值[分层遍历之一的扩展]

openGauss内核:简单查询的执行

我国SaaS产业的发展趋势与路径

Guava中这些Map的骚操作,让我的代码量减少了50%
随机推荐
降低pip到指定版本(通過PyCharm昇級pip,在降低到原來版本)
Collapse code using region
直击“三夏”生产:丰收喜报频传 夏播紧锣密鼓
【OpenCV 例程200篇】209. HSV 颜色空间的彩色图像分割
如何化解35岁危机?华为云数据库首席架构师20年技术经验分享
C语言-关键字1
【论】A deep-learning model for urban traffic flow prediction with traffic events mined from twitter
CV2 package guide times could not find a version that satisfies the requirement CV2 (from versions: none)
Multi task model of recommended model: esmm, MMOE
About transform InverseTransformPoint, transform. InverseTransofrmDirection
[theory] deep learning in the covid-19 epic: a deep model for urban traffic revitalization index
煮茶论英雄!福建省发改委、市营商办领导一行莅临育润大健康事业部交流指导
Reduce the pip to the specified version (upgrade the PIP through pycharm, and then reduce it to the original version)
Excel布局
How to resolve the 35 year old crisis? Sharing of 20 years' technical experience of chief architect of Huawei cloud database
Byte software testing basin friends, you can change jobs. Is this still the byte you are thinking about?
socket done
机器学习:梯度下降法
并查集+建图
leetcode1720_2021-10-14