Educational Codeforces Round 95 (Rated for Div. 2)
for Codeforces div round 95 Educational Rated
2023-09-27 14:27:31 时间
Powered by:AB_IN 局外人
A. Buying Torches
真得好好吐槽一下。
样例出错两次,数据出错一次。
讲一下我的思路吧。
- 首先先明确至少需要多少个棍。 k k k个火炬,至少需要 k ∗ y + k k*y+k k∗y+k个棍棍。
- 其次要想,怎么从
1
1
1个棍,利用第一条贸易,变成
k
∗
y
+
k
k*y+k
k∗y+k个棍。我们可以先通过观察,假设
x
=
12
x=12
x=12。那么
1 − > 12 1->12 1−>12 12 − > 23 12->23 12−>23 23 − > 34 23->34 23−>34
可以发现每次加 11 11 11,也就是 x − 1 x-1 x−1
所以,设 t m p tmp tmp是贸易一的次数。
1 + ( x − 1 ) ∗ t m p − > k ∗ y + k 1+(x-1)*tmp->k*y+k 1+(x−1)∗tmp−>k∗y+k
这里我为什么要用 − > -> −>而不是 = = =呢?
因为可能不能正好等于 k ∗ y + k k*y+k k∗y+k。
那就取
1 + ( x − 1 ) ∗ t m p > k ∗ y + k 1+(x-1)*tmp>k*y+k 1+(x−1)∗tmp>k∗y+k
时 t m p tmp tmp的值.
最后 t m p tmp tmp再加上贸易二的 k k k次即可。
for _ in range(int(input())):
x,y,k=map(int,input().split())
tmp=(k*y+k-1)//(x-1)
if tmp*(x-1)<k*y+k-1:
tmp+=1
tmp+=k
print(tmp)
B. Negative Prefixes
模拟题,记录可以动的,从大到小排序。
for _ in range(int(input())):
n=int(input())
lst=list(map(int,input().split()))
s=list(map(int,input().split()))
index=[]
t=[]
for i in range(n):
if s[i]==0:
index.append(i)
t.append(lst[i])
if len(t)==0:
print(*lst)
continue
t.sort(reverse=True)
for i in range(len(index)):
lst[index[i]]=t[i]
print(*lst)
实在困得不行了。。随便签个到bia。
完结。
相关文章
- Password expiration policy Security baseline (FINAL) for Windows 10 v1903 and Windows Server v1903
- Analytics Reporting API Client Library for .NET
- Aspose.Words for .NET使用表格教程之在表格中设置自动调整设置
- Educational Codeforces Round 133 (Rated for Div. 2) A 2-3 Moves
- Distributed systems theory for the distributed systems engineer
- for循环
- arcgis api 3.x for js 共享干货系列之二自定义 Navigation 控件样式风格(附源码下载)
- Deep Learning for Nature Language Processing --- 第四讲(下)
- visual studio 2019安装entity framework for mysql entity framework报错 由于以下异常而无法生成模型:’System.Data.StrongTypingException:表’TableDetails’中列’IsPrimaryKey’的值为DBNull
- Git for Windows之推送本地版本库到远程仓库
- Navicat连接kali数据库时,登录出现Access denied for user ‘root‘@‘localhost‘ (using password YES) 拒绝访问