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/ ...
随机推荐
- QMainFrame类
一.简介: 1.QMainFrame类提供了应用程序的主窗口,因为它可以添加菜单.工具条.状态栏和停靠窗口,同时也支持单文档窗口和多文档窗口,这是它和其他窗口不一样的地方. 2.QMainFrame窗 ...
- django学习笔记(四)表单
1.若用户刷新一个包含POST表单的页面,那么请求将会重新发送造成重复. 这通常会造成非期望的结果,比如说重复的数据库记录.如果用户在POST表单之后被重定向至另外的页面,就不会造成重复的请求了.我们 ...
- luogu1901 发射站
单调栈 正着插一遍反着插一遍 记录每个点左边右边第一个比他高的... yyc太强辣 #include<iostream> #include<cstdlib> #include& ...
- ACM学习历程—HDU5587 Array(数学 && 二分 && 记忆化 || 数位DP)(BestCoder Round #64 (div.2) 1003)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5587 题目大意就是初始有一个1,然后每次操作都是先在序列后面添加一个0,然后把原序列添加到0后面,然后 ...
- ACM学习历程—51NOD1028 大数乘法V2(FFT)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1028 题目大意就是求两个大数的乘法. 但是用普通的大数乘法,这 ...
- params 和 query 传参的区别
很多人都知道params 和 query 都可以在页面跳转的时候传递参数. query更加类似于我们ajax中get传参,params则类似于post,说的再简单一点,前者在浏览器地址栏中显示参数 ...
- BZOJ4364:[IOI2014]Wall
浅谈区间最值操作与历史最值问题:https://www.cnblogs.com/AKMer/p/10225100.html 题目传送门:https://lydsy.com/JudgeOnline/pr ...
- java ----一个函数传回多个值的总结
java 一个函数如何返回多个值 参考方法: 1.使用map返回值:这个方法问题是,你并不知道如何返回值的key是什么,只能通过doc或者通过源代码来查看. 2.传入一个引用进去,修改引用的属性值.问 ...
- VisualGDB系列2:VisualGDB对Linux平台的支持特性
根据VisualGDB官网(https://visualgdb.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指正. 1 复杂问题的直观解决方案 只需要轻点几 ...
- JavaScript设模式---单例模式
单例模式也称为单体模式,其中: 1,单体模式用于创建命名空间,将系列关联的属性和方法组织成一个逻辑单元,减少全局变量. 逻辑单元中的代码通过单一的变量进行访问. 2,三个特点: ① 该类只有一个实例: ...