940B Our Tanya is Crying Out Loud】的更多相关文章

传送门 题目大意 给你n,k,A,B四个数,x=n,有两种操作: 1.将x-1,需支付A个金币 2.将x÷k,需支付B个金币,当且仅当k能整除x时可进行此操作 问将x修改为1至少要花几个金币 分析 模拟两个过程,如果k能整除x则判断一个一个将x减到想x/k和将x除以k哪个花费的金币少,否则如果x大于k将x减去x模k的余数(不可每次减1,减若干次,否则会超时),x小于k则减去(x-1).注意特判k等于1的情况. 代码 #include<iostream>#include<cstdio>…
B. Our Tanya is Crying Out Loud time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A an…
B. Our Tanya is Crying Out Loud time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k,…
Our Tanya is Crying Out Loud time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A a…
题意(Codeforces 940B) 对一个数字$x$,你有两个决策:花费$A$减一.或花费$B$除以$k$(但必须可以除尽).问使之到$1$的最少花费. 分析 贼鸡儿简单,但我花式犯蠢……如果除不尽,那么直接用法一减到可以除得尽的:然后比较法一和法二哪个耗费得少,然后继续如上操作直到$x=1$.典型的贪心算法.是不是看起来很美?做梦啊!!对于法一,当$x<k$,不能减到除得尽(0)!对于比较耗费,如果$k=1$,只能选择法一,哪怕法二再怎么耗费少都不能啊啊啊啊……这两个坑踩过去了题目一点难度…
http://codeforces.com/problemset/problem/940/B Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two ty…
从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Numbers Problem D Alena And The Heater Problem E Cashback Problem F Machine Learning 小结 这场比赛和同学一起打.本来应该是很开心的事情,结果留下好多遗憾. 第一个遗憾是没能在20分钟内消灭A.B题.然后分数就不是很可观…
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权值小于等于给定值d 题解: 排序,每次挑最大的和最小的,看看最小的能跟多少个数差\(>d\),看看最大的能跟多少个数差\(>d\),取个数大的那个删除.复杂度\(n^2 + n\log n\) 代码 #include <iostream> #include <cstdio>…
所有的题目都可以在CodeForces上查看 中间看起来有很多场比赛我没有写了 其实是因为有题目没改完 因为我不想改,所以就没有写了(大部分题目还是改完了的) 我还是觉得如果是打了的比赛就一场一场写比较好 要不然以后就写有难度的.比较好的题目?? 这场比赛时间真心良心(只是没吃饭) 状态也很好,考场上把\(ABCDE\)切了 \(F\)是自己弃疗了... 不管啦不管啦,进入正题了 题解 A.Points on the line 翻译: 给定一个长度为\(n\)的数组 问最少删去几个数之后使得最大…
人生中第三次\(CF\)... 考试中切了\(A\)~\(E\) \(F\)题会做没时间写 题解 A:Points on the line 题意 给定一个数列,删最小的数,使最大差不大于一个定值 Sol 排序后选的一定是段连续的区间,枚举左右端点即可 手速慢了233 # include <bits/stdc++.h> # define RG register # define IL inline # define Fill(a, b) memset(a, b, sizeof(a)) using…
人生的大起大落莫过如此,下一场我一定要回紫. [A]Points on the line 题意: 一个直线上有\(n\)个点,要求去掉最少的点,使得最远两点距离不超过\(d\). 题解: 暴力两重for,更新答案. #include<cstdio> #include<algorithm> using namespace std; #define F(i,a,b) for(int i=(a);i<=(b);++i) int n,q,ans=0; int a[100001]; i…
A. Points on the line 题意 给定一条直线上\(n\)个点,要求去掉最少的点,使得直线上相距最远的两个点的距离\(\leq d\). 思路 枚举长度为\(d\)的区间. Code #include <bits/stdc++.h> #define F(i, a, b) for (int i = (a); i < (b); ++i) #define F2(i, a, b) for (int i = (a); i <= (b); ++i) #define dF(i,…
940和822两套div.2 老规矩 #define MAXN 1000000+5#define MOD 1000000007#define PI (acos(-1.0))#define EPS 1e-6#define MMT(s,a) memset(s, a, sizeof s)#define GO(i,a,b) for(int i = (a); i < (b); ++i)#define GOE(i,a,b) for(int i = (a); i <= (b); ++i)#define OG…
掉分经过 难得这次时间比较好,下午17:35开始. 本来还很高兴,心想这回肯定不会犯困,没准排名能再上升一些呢,,可惜事与愿违-- 上来a题,光看懂题就花了一些时间. 然后开始写,结果第一遍CE,第二遍WA-- 出师不利啊!气急败坏,暂时放弃. 然后看b题. 惊喜地发现这类似的题我做过,大概是个bfs?嗯dp也行? 结果发现\(n \leq 10^9\)...真不妙. 这时来了个有关a题的通知,于是又回去看a题. 终于找到之前代码中的问题了,过了pretest 接着c和d题做的还算顺利,1个小时…
airhead: stupid person. ace: excellent, great. Adam and Eve - Rhyming Slang for 'believe'. aggro - short for aggravation or violence. amber fluid : beer. anorak - geek, nerd. apples and pears - Rhyming Slang for 'stairs'. armpit: dirty, unappealing p…
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa's land. People in Arpa's land are numbered from 1…
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就将 s 这个数量加到 YAY! 的答案里,少于的话就加 t 中有的数量:如果 t 中有跟 s 相同的字母但是大小写不对应(例如A-a,z-Z),就加到 WHOOPS 的答案里. 举个例子就很容易明白了.例如 s 和 t 分别为: ncMeXssLHS uwyeMcaFatpInZVdEYpwJQSn…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of lengt…
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/B Description Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the v…
Description While dad was at work, a little girl Tanya decided to play with dad characters. She has written all the possible n three-letter continuous substrings of the password on pieces of paper, one for each piece of paper, and threw the password…
C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collectio…
Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1…
Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1to 109. A toy from the new collection of the i-th type costs i bourles. Tania has managed to collect n …
C. Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered fro…
Tanya and Candies time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tanya has nn candies numbered from 11 to nn . The ii -th candy has the weight aiai . She plans to eat exactly n−1n−1 candie…
Tanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai. She plans to eat exactly n−1n−1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day. You…
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of le…
C. Tanya and Toys 题目连接: http://www.codeforces.com/contest/659/problem/C Description In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new col…