当前位置:网站首页>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("");
}
}
边栏推荐
- 【论】A deep-learning model for urban traffic flow prediction with traffic events mined from twitter
- 心楼:华为运动健康的七年筑造之旅
- [camera Foundation (I)] working principle and overall structure of camera
- [theory] deep learning in the covid-19 epic: a deep model for urban traffic revitalization index
- 壹沓科技签约七匹狼,助力「中国男装领导者」数字化转型
- 2022国际女性工程师日:戴森设计大奖彰显女性设计实力
- 02--- impossible phenomenon of longitudinal wave
- Implementing DNS requester with C language
- [untitled]
- leetcode1720_2021-10-14
猜你喜欢

Multithreaded finalization
![[notes of Wu Enda] convolutional neural network](/img/19/2cac17010c29cbd5ba245de105d6c1.png)
[notes of Wu Enda] convolutional neural network

直击“三夏”生产:丰收喜报频传 夏播紧锣密鼓

Implementing DNS requester with C language

Blender FAQs

Transport layer UDP & TCP

cv2导包时报Could not find a version that satisfies the requirement cv2 (from versions: none)

Fuzhou business office of Fujian development and Reform Commission visited the health department of Yurun university to guide and inspect the work

leetcode:1504. 统计全 1 子矩形的个数

Installing Oracle without graphical interface in virtual machine centos7 (nanny level installation)
随机推荐
队列实现原理和应用
LeetCode-513. 找树左下角的值
即构「畅直播」上线!提供全链路升级的一站式直播服务
Réduire le PIP à la version spécifiée (mettre à jour le PIP avec pycharm avant de le réduire à la version originale)
Excel layout
【论】A deep-learning model for urban traffic flow prediction with traffic events mined from twitter
Getting started with typescript
栈的两种实现方式
PKI notes
好想送对象一束花呀
【Camera基础(一)】Camera摄像头工作原理及整机架构
Li Kou daily question - day 26 -496 Next larger element I
Based on asp Net development of fixed assets management system source code enterprise fixed assets management system source code
Mysql 通过表明获取字段以及注释
Multi task model of recommended model: esmm, MMOE
Object.defineProperty和Reflect.defineProperty的容错问题
想当测试Leader,这6项技能你会吗?
Transport layer UDP & TCP
socket(1)
VSCode无网环境快速迁移开发环境(VIP典藏版)