AtCoder Beginner Contest 083 (AB)
A - Libra
题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_a
Time limit : 2sec / Memory limit : 256MB
Score : 100 points
Problem Statement
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.
Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan.
Print Left
if the balance scale tips to the left; print Balanced
if it balances; print Right
if it tips to the right.
Constraints
- 1≤A,B,C,D≤10
- All input values are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print Left
if the balance scale tips to the left; print Balanced
if it balances; print Right
if it tips to the right.
Sample Input 1
3 8 7 1
Sample Output 1
Left
The total weight of the masses on the left pan is 11, and the total weight of the masses on the right pan is 8. Since 11>8, we should print Left
.
Sample Input 2
3 4 5 2
Sample Output 2
Balanced
The total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced
.
Sample Input 3
1 7 6 4
Sample Output 3
Right
The total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right
.
#include <iostream>
using namespace std;
int N,A,B;
int test(int x)
{
int sum=;
while(x){
sum+=x%;
x/=;
}
if(sum<=B&&sum>=A) return ;
else return ;
}
int main()
{ while(cin>>N>>A>>B){
int s=;
for(int i=;i<=N;i++){
if(test(i)) s+=i;
}
cout<<s<<endl;
}
return ;
}
B - Some Sums
题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_b
Time limit : 2sec / Memory limit : 256MB
Score : 200 points
Problem Statement
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
Constraints
- 1≤N≤104
- 1≤A≤B≤36
- All input values are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
Sample Input 1
20 2 5
Sample Output 1
84
Among the integers not greater than 20, the ones whose sums of digits are between 2 and 5, are: 2,3,4,5,11,12,13,14 and 20. We should print the sum of these, 84.
Sample Input 2
10 1 2
Sample Output 2
13
Sample Input 3
100 4 16
Sample Output 3
4554
#include <iostream>
using namespace std;
int N,A,B;
int test(int x)
{
int sum=;
while(x){
sum+=x%;
x/=;
}
if(sum<=B&&sum>=A) return ;
else return ;
}
int main()
{ while(cin>>N>>A>>B){
int s=;
for(int i=;i<=N;i++){
if(test(i)) s+=i;
}
cout<<s<<endl;
}
return ;
}
AtCoder Beginner Contest 083 (AB)的更多相关文章
- AtCoder Beginner Contest 084(AB)
A - New Year 题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_a Time limit : 2sec / Memory limit ...
- AtCoder Beginner Contest 254(D-E)
Tasks - AtCoder Beginner Contest 254 D - Together Square 题意: 给定一个N,找出所有不超过N的 ( i , j ),使得( i * j )是一 ...
- AtCoder Beginner Contest 086 (ABCD)
A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : ...
- AtCoder Beginner Contest 085(ABCD)
A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...
- AtCoder Beginner Contest 264(D-E)
D - "redocta".swap(i,i+1) 题意: 给一个字符串,每次交换相邻两个字符,问最少多少次变成"atcoder" 题解: 从左到右依次模拟 # ...
- Atcoder Beginner Contest 155E(DP)
#definde HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int main(){ ios: ...
- Atcoder Beginner Contest 156E(隔板法,组合数学)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ; long long fac[N] ...
- Atcoder Beginner Contest 121D(异或公式)
#include<bits/stdc++.h>using namespace std;int main(){ long long a,b; cin>>a>&g ...
- Atcoder Beginner Contest 155D(二分,尺取法,细节模拟)
二分,尺取法,细节模拟,尤其是要注意a[i]被计算到和a[i]成对的a[j]里时 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...
随机推荐
- 结合python+selenium使用AutoIt V3实现文件、图片上传
1.下载.安装AutoIt V3 下载官网:https://www.autoitscript.com/site/autoit/downloads/ 2.AutoIt V3组件介绍 AutoIt Win ...
- 001-快速搭建Spring web应用【springboot 2.0.4】-gradle、springboot的启动过程分析、gradle多模块构建
一.概述 学习<精通Spring MVC4>书籍笔记 二.笔记 1.快速构建Spring starter web项目几种方式 1>使用Spring Tool Suite生成Start ...
- 清空select标签中option选项的3种不同方式
方法一 代码如下:document.getElementById("selectid").options.length = 0; 方法二 代码如下:document.formNam ...
- vue 动态绑定背景图片
html <div class="racetm" :style="{backgroundImage: 'url(' + (coverImgUrl ? coverIm ...
- mac上mysql root密码忘记或权限错误的解决办法
以下方法亲测有效,过程使用的工具只有mac的终端无需workbench 当我们通过终端连接mysql数据库时候我们会看到这样的信息 ERROR 1045: Access denied for user ...
- java实现的加密解密
void encode(File enfile, File defile) throws Exception { String Algorithm = "DES"; byte[] ...
- 天猫京东app中常见的上下滚动轮播效果如何实现?
前段时间,公司安排我制作一个上下滚动轮播效果,类似于我们在天猫京东app中常见的这样: 哇kao!这个我完全不会呀??? 幸好,前几天一个朋友在朋友圈分享了一篇推文.瞬间引领我走出了迷茫,这个教程特别 ...
- node-rsa 非对称加密和解密
使用公钥和私钥的加密和解密: 非对称加密的关键在于 有 公钥 / 私钥用法:a.生成一对公钥私钥b.公钥加密 -> 对应私钥解密c.私钥加密 -> 对应公钥解密 非对称加密的常见应用方式a ...
- Dropout正则化和其他方法减少神经网络中的过拟合
1. 什么是Dropout(随机失活) 就是在神经网络的Dropout层,为每个神经元结点设置一个随机消除的概率,对于保留下来的神经元,我们得到一个节点较少,规模较小的网络进行训练. 标准网络和dro ...
- android 流程跟踪
#记录一下 Thread cur_thread = Thread.currentThread(); StackTraceElement stack[] = cur_thread.getStackTra ...