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

Copy
3 8 7 1

Sample Output 1

Copy
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

Copy
3 4 5 2

Sample Output 2

Copy
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

Copy
1 7 6 4

Sample Output 3

Copy
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≤AB≤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

Copy
20 2 5

Sample Output 1

Copy
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

Copy
10 1 2

Sample Output 2

Copy
13

Sample Input 3

Copy
100 4 16

Sample Output 3

Copy
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)的更多相关文章

  1. AtCoder Beginner Contest 084(AB)

    A - New Year 题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_a Time limit : 2sec / Memory limit  ...

  2. AtCoder Beginner Contest 254(D-E)

    Tasks - AtCoder Beginner Contest 254 D - Together Square 题意: 给定一个N,找出所有不超过N的 ( i , j ),使得( i * j )是一 ...

  3. AtCoder Beginner Contest 086 (ABCD)

    A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : ...

  4. AtCoder Beginner Contest 085(ABCD)

    A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...

  5. AtCoder Beginner Contest 264(D-E)

    D - "redocta".swap(i,i+1) 题意: 给一个字符串,每次交换相邻两个字符,问最少多少次变成"atcoder" 题解: 从左到右依次模拟 # ...

  6. Atcoder Beginner Contest 155E(DP)

    #definde HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int main(){ ios: ...

  7. Atcoder Beginner Contest 156E(隔板法,组合数学)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ; long long fac[N] ...

  8. Atcoder Beginner Contest 121D(异或公式)

    #include<bits/stdc++.h>using namespace std;int main(){    long long a,b;    cin>>a>&g ...

  9. Atcoder Beginner Contest 155D(二分,尺取法,细节模拟)

    二分,尺取法,细节模拟,尤其是要注意a[i]被计算到和a[i]成对的a[j]里时 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...

随机推荐

  1. 微信小程序添加悬浮在线客服会话按钮

    微信为小程序提供客服消息能力,小程序用户可以方便快捷地与小程序服务提供方进行沟通,并且已经做成了组件的形式,直接就可以调用.客服会话按钮,用于在页面上显示一个客服会话按钮,用户点击该按钮后会进入客服会 ...

  2. MySQL中的数据类型以及完整性约束

    数据类型 数据库mysql中也是分很多数据类型的,最常用的就是:数字类型.字符类型.日期类型.枚举与集合类型 一.数字类型: 默认都是有符号的,即正负号,若想无符号,在创建表时加unsigned.指定 ...

  3. MySQL 5.7 新特性大全和未来展望

    引用 美图公司数据库高级 DBA,负责美图后端数据存储平台建设和架构设计.前新浪高级数据库工程师,负责新浪微博核心数据库架构改造优化,以及数据库相关的服务器存储选型设计.之前在「高可用架构」发表的&l ...

  4. Java中基本数据类型byte,short,char,int,long,float,double 取值范围

    部分内容转自:java 彻底理解 byte char short int float long double 首先说byte: 这段是摘自jdk中 Byte.java中的源代码: /** * A co ...

  5. abap对象的创建和调用。方法调用

    1: abap中创建类和创建对象,调用方法. *&---------------------------------------------------------------------* ...

  6. HBase学习总结(1)

    HBase是一种数据库:HadoopDatabase顾名思义就是Hadoop数据库,它是一种基于hadoop文件系统HDFS的一种分布式数据库,专门设计用来快速随机读写大规模数据.本文介绍HBase的 ...

  7. [LeetCode] 506. Relative Ranks_Easy tag: Sort

    Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...

  8. 软件测试常用Linux命令

    有些技能可以事半功倍,有些命运掌握在我们手中.熟练的掌握和使用这些命令可以提高工作效率,并且结合这些命令对测试过程中遇到的问题进行一些初步的定位. 1 目录与文件操作 1.1 ls(初级) 使用权限: ...

  9. iOS UI进阶-4.0 地图与定位

    在移动互联网时代,移动app能解决用户的很多生活琐事,比如 导航:去任意陌生的地方 周边:找餐馆.找酒店.找银行.找电影院   在上述应用中,都用到了地图和定位功能,在iOS开发中,要想加入这2大功能 ...

  10. Android提权漏洞CVE-2014-7920、CVE-2014-7921