A. Coins

Water.

 #include <bits/stdc++.h>
using namespace std;
int n, s; int main()
{
while (scanf("%d%d", &n, &s) != EOF)
{
int res = ;
for (int i = n; i >= ; --i) while (s >= i)
{
++res;
s -= i;
}
printf("%d\n", res);
}
return ;
}

B. Views Matter

Solved.

题意:

有n个栈,不受重力影响,在保持俯视图以及侧视图不变的情况下,最多可以移掉多少个方块

思路:

考虑原来那一列有的话那么这一列至少有一个,然后贪心往高了放

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 100010
int n, m;
ll a[N], sum; int main()
{
while (scanf("%d%d", &n, &m) != EOF)
{
sum = ;
for (int i = ; i <= n; ++i) scanf("%lld", a + i), sum += a[i];
sort(a + , a + + n);
ll res = , high = ;
for (int i = ; i <= n; ++i) if (a[i] > high)
++high;
printf("%lld\n", sum - n - a[n] + high);
}
return ;
}

C. Multiplicity

Upsolved.

题意:

定义一个序列为好的序列即$b_1, b_2, ...., b_k 中i \in [1, k] 使得 b_i % i == 0$

求有多少个好的子序列

思路:

考虑$Dp$

$令dp[i][j] 表示第i个数,长度为j的序列有多少种方式$

$dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]   (arr[j] % j == 0)$

否则 $dp[i][j] = dp[i - 1][j]$

然后不能暴力递推,只需要更新$arr[j] % j == 0 的j即可$

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 1000100
const ll MOD = (ll)1e9 + ;
int n; ll a[N], dp[N]; int main()
{
while (scanf("%d", &n) != EOF)
{
for (int i = ; i <= n; ++i) scanf("%lld", a + i);
memset(dp, , sizeof dp);
dp[] = ;
for (int i = ; i <= n; ++i)
{
vector <int> cur;
for (int j = ; j * j <= a[i]; ++j)
{
if (a[i] % j == )
{
cur.push_back(j);
if (j != a[i] / j)
cur.push_back(a[i] / j);
}
}
sort(cur.begin(), cur.end());
reverse(cur.begin(), cur.end());
for (auto it : cur)
dp[it] = (dp[it] + dp[it - ]) % MOD;
}
ll res = ;
for (int i = ; i <= ; ++i) res = (res + dp[i]) % MOD;
printf("%lld\n", res);
}
return ;
}

D. TV Shows

Upsolved.

题意:

有n个电视节目,每个节目播放的时间是$[l, r],租用一台电视机的费用为x + y \cdot time$

一台电视机同时只能看一个电视节目,求看完所有电视节目最少花费

思路:

贪心。

因为租用电视机的初始费用是相同的,那么我们将电视节目将左端点排序后

每次选择已经租用的电视机中上次放映时间离自己最近的,还要比较租用新电视机的费用,

如果是刚开始或者没有一台电视机闲着,则需要租用新的电视机

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 100010
struct node
{
ll l, r;
void scan() { scanf("%lld%lld", &l, &r); }
bool operator < (const node &r) const
{
return l < r.l || (l == r.l && this->r < r.r);
}
}arr[N];
int n; ll x, y;
const ll MOD = (ll)1e9 + ;
multiset <ll> se; int main()
{
while (scanf("%d%lld%lld", &n, &x, &y) != EOF)
{
for (int i = ; i <= n; ++i) arr[i].scan();
sort(arr + , arr + + n);
ll res = ;
for (int i = ; i <= n; ++i)
{
if (se.lower_bound(arr[i].l) == se.begin())
res = (res + x + y * (arr[i].r - arr[i].l) % MOD) % MOD;
else
{
int pos = *(--se.lower_bound(arr[i].l));
if (x < y * (arr[i].l - pos))
res = (res + x + y * (arr[i].r - arr[i].l) % MOD) % MOD;
else
{
se.erase(--se.lower_bound(arr[i].l));
res = (res + y * (arr[i].r - pos) % MOD) % MOD;
}
}
se.insert(arr[i].r);
}
printf("%lld\n", res);
}
return ;
}

E. Politics

Unsolved.

F. Lost Root

Unsolved.

Codeforces Round #523 (Div. 2) Solution的更多相关文章

  1. Codeforces Round #523 (Div. 2)

    Codeforces Round #523 (Div. 2) 题目一览表 来源 考察知识点 完成时间 A Coins cf 贪心(签到题) 2018.11.23 B Views Matter cf 思 ...

  2. Codeforces Round #466 (Div. 2) Solution

    从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Nu ...

  3. 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution

    对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...

  4. Codeforces Round #545 (Div. 1) Solution

    人生第一场Div. 1 结果因为想D想太久不晓得Floyd判环法.C不会拆点.E想了个奇奇怪怪的set+堆+一堆乱七八糟的标记的贼难写的做法滚粗了qwq靠手速上分qwqqq A. Skyscraper ...

  5. Codeforces Round 500 (Div 2) Solution

    从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemica ...

  6. Codeforces Round #523 (Div. 2) E. Politics(最小费+思维建图)

    https://codeforces.com/contest/1061/problem/E 题意 有n个点(<=500),标记第i个点的代价a[i],然后分别在这n个点建两棵树,对于每颗树的每个 ...

  7. Codeforces Round #523 (Div. 2) F. Katya and Segments Sets (交互题+思维)

    https://codeforces.com/contest/1061/problem/F 题意 假设存在一颗完全k叉树(n<=1e5),允许你进行最多(n*60)次询问,然后输出这棵树的根,每 ...

  8. Codeforces Round #607 (Div. 1) Solution

    从这里开始 比赛目录 我又不太会 div 1 A? 我菜爆了... Problem A Cut and Paste 暴力模拟一下. Code #include <bits/stdc++.h> ...

  9. Codeforces Round #578 (Div. 2) Solution

    Problem A Hotelier 直接模拟即可~~ 复杂度是$O(10 \times n)$ # include<bits/stdc++.h> using namespace std; ...

随机推荐

  1. break、continue、return之间的区别与联系

    今天在部署程序的时候,监控日志发现这个问题了.return的问题就这么总结哈. 在软件开发过程中,逻辑清晰是非常之重要的. 代码的规范也是非常重要的.往往细节决定成败.在编写代码的时候,一定要理解语言 ...

  2. HttpServletResponse status对应的状态信息

    1xx - 信息提示   这些状态代码表示临时的响应.客户端在收到常规响应之前,应准备接收一个或多个 1xx 响应.    ·0 - 本地响应成功.   · 100 - Continue 初始的请求已 ...

  3. cocos2d-x游戏引擎核心之七——数据持久化

    一.XML与JSON XML 和 JSON 都是当下流行的数据存储格式,它们的共同特点就是数据明文,十分易于阅读.XML 源自于 SGML,是一种标记性数据描述语言,而 JSON 则是一种轻量级数据交 ...

  4. 预装的Office2016,文件图标表显示以及新建失败问题解决 方法

    新购买笔记本电脑,预装的office2016 学生版 启动激活后,会出现文件图标异常, 文件的类型为: ms-resource:Strings/FtaDisplayName.docx (.docx) ...

  5. 【转载】为ASP.NET MVC及WebApi添加路由优先级

    路由方面的: 转载地址:http://www.jb51.net/article/73417.htm Author:lijiao 这是一个对Asp.Net Mvc的一个很小的功能拓展,小项目可能不太需要 ...

  6. Java 去除List列表中的重复项

    /** * Remove list duplicate item * * @param srcList * @return */ private static ArrayList<Resolve ...

  7. 【Android】Android背景选择器selector用法汇总

    一.创建xml文件,位置:drawable/xxx.xml,同目录下记得要放相关图片 <?xml version="1.0" encoding="utf-8&quo ...

  8. MYSQL-max_binlog_cache_size参数

    max_binlog_cache_size 解释:这是设置最大二进制日志的缓存区大小的变量.若处理多语句事务时需要的内存大小比设置值大的话就会提示一个error:Multi-statement tra ...

  9. thinkphp --- 写入日志

    在开发过程中,对于一些参数,不好直接输入或者打印调试,特别是在微信开发过程中,这个时候,通过日志来查看信息就显得格外重要. 下面是在TP3.2.3框架中,写入日志的方法: public functio ...

  10. 微信开发(3):微信公众号发现金红包功能开发,利用第三方SDK实现(转)

    最近需求是 用户兑换微信红包,需要一些验证,加密,以及证书: 工欲善其事必先利其器 感谢前辈的微信SDK 已经维护三年了,还在维护中! 官方文档走一波 文档还是一如既往的 坑人啊,写的很简单,对简单明 ...