AtCoder Beginner Contest 121 题解
题目链接:https://atcoder.jp/contests/abc121
A White Cells
分析:题目数据规模很小,直接暴力修改都可以。或者可以推出公式
.
代码:
#include <iostream>
#include <cstdio> using namespace std; int main()
{
int a[][] = {};
int H, W, h, w;
scanf("%d %d", &H, &W);
scanf("%d %d", &h, &w);
for(int i = ; i < h; ++i)
for(int j = ; j < W; ++j)
a[i][j] = ;
for(int i = ; i < w; ++i)
for(int j = ; j < H; ++j)
a[j][i] = ;
int ans = ;
for(int i = ; i < H; ++i)
{
for(int j = ; j < W; ++j)
{
if(a[i][j] == )
++ans;
}
}
printf("%d\n", ans);
return ;
}
B Can you solve this?
分析:模拟即可。
代码:
#include <iostream>
#include <cstdio> using namespace std; int main()
{
int n, m, c;
scanf("%d %d %d", &n, &m, &c);
int b[];
for(int i = ; i < m; ++i)
scanf("%d", &b[i]);
int ans = ;
for(int i = ; i < n; ++i)
{
int tmp, sum = ;
for(int j = ; j < m; ++j)
{
scanf("%d", &tmp);
sum += tmp * b[j];
}
if(sum + c > )
++ans;
}
printf("%d\n", ans);
return ;
}
C Energy Drink Collector
分析:贪心+模拟即可。
代码:
#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; typedef long long ll; struct store
{
ll a;
ll b;
}sl[]; bool cmp(store x, store y)
{
return x.a < y.a;
} int main()
{
ll n, m;
cin>>n>>m;
for(int i = ; i < n; ++i)
{
cin>>sl[i].a>>sl[i].b;
}
sort(sl, sl + n, cmp);
ll ans = , sum = ;
for(int i = ; i < n; ++i)
{
if(sum + sl[i].b >= m)
{
ans += (m - sum) * sl[i].a;
break;
}
else
{
sum += sl[i].b;
ans += sl[i].b * sl[i].a;
}
}
cout<<ans<<endl;
return ;
}
D XOR World
分析:首先异或运算有个性质:
,这样我们只要看
具有的性质即可。打表可以发现有以下规律:

据此,我们可以写出代码。注意对于A为0要特判一下。
代码:
#include <iostream> using namespace std; typedef long long ll; ll myxor(ll a)
{
if(a % == )
return ;
else if(a % == )
return a + ;
else if(a % == )
return ;
else
return a;
} int main()
{
ll a, b;
cin>>a>>b;
if(a == )
cout<<b<<endl;
else
cout<<((myxor(b))^(myxor(a-)))<<endl;
return ;
}
AtCoder Beginner Contest 121 题解的更多相关文章
- AtCoder Beginner Contest 154 题解
人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...
- AtCoder Beginner Contest 153 题解
目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...
- AtCoder Beginner Contest 177 题解
AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C ...
- AtCoder Beginner Contest 184 题解
AtCoder Beginner Contest 184 题解 目录 AtCoder Beginner Contest 184 题解 A - Determinant B - Quizzes C - S ...
- AtCoder Beginner Contest 173 题解
AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...
- AtCoder Beginner Contest 172 题解
AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...
- AtCoder Beginner Contest 169 题解
AtCoder Beginner Contest 169 题解 这场比赛比较简单,证明我没有咕咕咕的时候到了! A - Multiplication 1 没什么好说的,直接读入两个数输出乘积就好了. ...
- AtCoder Beginner Contest 148 题解
目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...
- AtCoder Beginner Contest 151 题解报告
总的来说,这次的题目比较水,然而菜菜的我并没有把所有题目都做完,话不多说,直接来干货: A:Next Alphabet 题目链接:https://atcoder.jp/contests/abc151/ ...
随机推荐
- C++中函数重载
C++中函数重载使用顶层const修饰参数和不使用const修饰参数效果是一样的,如果定义了这样的重载函数会报函数重定义的错误. 追其原因,C++中的函数传递方式有三种,一种是值传递,就是拷贝,一种是 ...
- 设置Suse linux 用户远程登录超时时间
执行 # echo "export TMOUT=900" >> /etc/profile 查询设置结果: # cat /etc/profile|grep TMOU ...
- 每天一个linux命令(10):touch命令
版权声明更新:2017-05-14博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的mv命令. 2. ...
- 【LeetCode】010. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- 多版本Python共存时pip给指定版本的python安装package的方法
在Linux安装了多版本Python时(例如python2.7和3.6),pip安装的包不一定是用户想要的位置,此时可以用 -t 选项来指定位置. 例如目标位置是/usr/local/lib/pyth ...
- python mysql 查询返回字典结构
cur = self.conn.cursor(MySQLdb.cursors.DictCursor)加上MySQLdb.cursors.DictCursor可以返回字典结构 {列名:值} class ...
- C#分词算法
本文用到的库下载:点此下载 词库下载:点此下载 将词库直接放到项目根目录 词库设置如下: 类库说明 词库查看程序:点此下载 可以在上面的程序中添加常用行业词库 还可以通过下面的类在程序中实现 完整的盘 ...
- SQL连接、嵌套和集合查询---
SQL连接.嵌套和集合查询 一:连接查询 1 .不同表之间的连接查询 例 查询每个学生及其选修课程的情况. 本查询实际上是涉及Students与Reports两个表的连接操作.这两个表之间的联系是通过 ...
- Mysql 数据库时间更新字段
关于时间更新: 创建时间: CURRENT_TIMESTAMP 更新时间: 勾选根据时间戳更新
- .Net下RabbitMQ发布订阅模式实践
一.概念AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计.消息中间件主要用于组件之间的解耦,消息的发 ...