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/ ...
随机推荐
- Java钉钉开发_异常_01_error code:50002, error message:请求的员工userid不在授权范围内
一.异常原因: 请求的员工不在 应用的可见范围内. 如下图,应用的可见范围只设置为了部分员工.所以导致此异常 二.异常解决 将员工添加进可见范围即可
- 本地未安装Oracle数据库,如何连接远程Oracle数据库
方法一:用Navicat Premium连接 注意,这里用的要是黄色的版本,而不是只针对Mysql的绿色版本 工具栏选择[工具]-[选项],点击[其他-OCI] 你会发现有个OCI librar ...
- ACM学习历程—UESTC 1218 Pick The Sticks(动态规划)(2015CCPC D)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 题目大意就是求n根木棒能不能放进一个容器里,乍一看像01背包,但是容器的两端可以溢出容器,只要两端的木 ...
- Oracle 12c 多租户 CDB 与 PDB 级别 expdb 与 impdb(表、用户、全库)
Oracle 数据库 12 c 多租户下,如何在容器数据库 (CDB) 和可插拔数据库 (PDB) 中使用 expdb 与 impdp (数据泵) 呢? 我们一起探讨下PDB 下进行表级,用户级别,全 ...
- Operating System-Thread(4) 线程的调度激活机制(Scheduler Activations)
本文主要介绍线程的调度激活机制(Scheduler Activations),主要内容: 调度激活机制简介 上行调用(upcall) 中断处理(Interrupt) 一. 调度激活机制简介 上一篇文章 ...
- app专项测试(稳定性测试、安全性测试)
https://blog.csdn.net/xiaomaoxiao336368/article/details/84887948
- 【转】 Pro Android学习笔记(十九):用户界面和控制(7):ListView
目录(?)[-] 点击List的item触发 添加其他控件以及获取item数据 ListView控件以垂直布局方式显示子view.系统的android.app.ListActivity已经实现了一个只 ...
- 转载:oracle用户创建及权限设置
权限: create session create table unlimited tablespace connect resource dba 例: #sqlplus /nolog SQL> ...
- javaScript之Array方法
Array类型和其他语言一样,是数据的有序列表,但不同的是数组的每一项们可以保存任何类型的数据. 1.检测方法(确定某个对象是不是数组) (1)value instanceof Array (2)Ar ...
- JavaScript中设置cookie的值
cookie 与 session 是网页开发中常用的信息存储方式.Cookie是在客户端开辟的一块可存储用户信息的地方:Session是在服务器内存中开辟的一块存储用户信息的地方.JavaScript ...