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> ...
随机推荐
- 前端 HTML标签属性
HTML标签可以设置属性,如下: <div id="i1">这是一个div标签</div> <p class='p1 p2 p3'>这是一个段落 ...
- 调用finecms栏目多图怎么实现
finecms栏目自定义字段添加图集怎么调用出来?已经上传两张图片了,点击可以预览图片,前端显示不了,如下图所示.调用栏目多图这个要涉及到二次开发,首先要先添加栏目自定义字段,设为文件的格式,然后可以 ...
- dataframe操作
1.去除重复项drop_duplication #去除重复项drop_duplication import pandas as pd df = pd.DataFrame({"col1&quo ...
- awk命令分析日志的简单笔记
awk是一个文本分析工具,可以用来进行流量日志分析 之前无意中看到了这个命令,简单记一下笔记 ,在打线下的时候可能会有用 awk有3个不同版本: awk.nawk和gawk,未作特别说明,一般指gaw ...
- ElasticSearch6.2.3安装Head插件
1.环境 Linux centos7 elasticsearch-head的zip包,github网址如下:https://github.com/mobz/elasticsearch-head nod ...
- Linux下修改MySQL数据库字符编码为UTF-8解决中文乱码
由于MySQL编码原因会导致数据库出现乱码. 解决办法: 修改MySQL数据库字符编码为UTF-8,UTF-8包含全世界所有国家需要用到的字符,是国际编码. 具体操作: 1.进入MySQL控制台 &g ...
- Golang mysql
还是那句话,服务器嘛,每个数据库支持,那成啥子啦嘛! 好吧,今天,就让Go能连上数据库,当然是之前给你铺垫的MySql的啦,哈哈 一.安装第三方包支持访问mysql数据库 #go get github ...
- WCF&AppFabric :异常消息: 内存入口检查失败
bug描述 发件人信息: System.ServiceModel.ServiceHostingEnvironment+HostingManager/31242459 异常: System.Servic ...
- Reveal使用
本人手机是7.1的,reveal2.0以后不支持8.0以下,没办法,这里只能使用reveal1.6. 这里提醒一下,reveal2.0以后libReavel.lib改名了,. https://reve ...
- css省...和div 内容过多,自动换行
1.shengluohao 就是这个... 加: overflow: hidden;/*超出部分隐藏*/ white-space: nowrap;/*不换行*/ text-overflow:ellip ...