A - Already 2018

题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a

Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 232018 should be written as 2018/01/23.

After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.

Constraints

  • S is a string of length 10.
  • The first eight characters in S are 2017/01/.
  • The last two characters in S are digits and represent an integer between 1 and 31 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

Replace the first four characters in S with 2018 and print it.


Sample Input 1

Copy
2017/01/07

Sample Output 1

Copy
2018/01/07

Sample Input 2

Copy
2017/01/31

Sample Output 2

Copy
2018/01/31
 #include <iostream>
using namespace std;
int main()
{
string s;
while(cin>>s){
int l=s.length();
for(int i=;i<l;i++){
if(i==) cout<<'';
else if(i==) cout<<'';
else if(i==) cout<<'';
else if(i==) cout<<'';
else cout<<s[i];
}
cout<<endl;
}
return ;
}

B - Kagami Mochi

题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_b

Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

An X-layered kagami mochi (X≥1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 108 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.

Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is di centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Constraints

  • 1≤N≤100
  • 1≤di≤100
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N
d1
:
dN

Output

Print the maximum number of layers in a kagami mochi that can be made.


Sample Input 1

Copy
4
10
8
8
6

Sample Output 1

Copy
3

If we stack the mochi with diameters of 108 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.


Sample Input 2

Copy
3
15
15
15

Sample Output 2

Copy
1

When all the mochi have the same diameter, we can only have a 1-layered kagami mochi.


Sample Input 3

Copy
7
50
30
50
100
50
80
30

Sample Output 3

Copy
4

题解:计算一堆数里最大不重复的个数
 #include <iostream>
#include <set>
using namespace std;
int main()
{
int n;
set<int> s;
while(cin>>n){
s.clear();
while(n--){
int x;
cin>>x;
s.insert(x);
}
int sum=s.size();
cout<<sum<<endl;
}
return ;
}

C - Otoshidama

题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_c

Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.

According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Constraints

  • 1≤N≤2000
  • 1000≤Y≤2×107
  • N is an integer.
  • Y is a multiple of 1000.

Input

Input is given from Standard Input in the following format:

N Y

Output

If the total value of N bills cannot be Y yen, print -1 -1 -1.

If the total value of N bills can be Y yen, let one such set of bills be "x 10000-yen bills, y 5000-yen bills and z 1000-yen bills", and print xyz with spaces in between. If there are multiple possibilities, any of them may be printed.


Sample Input 1

Copy
9 45000

Sample Output 1

Copy
4 0 5

If the envelope contained 4 10000-yen bills and 5 1000-yen bills, he had 9 bills and 45000 yen in total. It is also possible that the envelope contained 9 5000-yen bills, so the output 0 9 0 is also correct.


Sample Input 2

Copy
20 196000

Sample Output 2

Copy
-1 -1 -1

When the envelope contained 20 bills in total, the total value would be 200000 yen if all the bills were 10000-yen bills, and would be at most 195000 yen otherwise, so it would never be 196000 yen.


Sample Input 3

Copy
1000 1234000

Sample Output 3

Copy
14 27 959

There are also many other possibilities.


Sample Input 4

Copy
2000 20000000

Sample Output 4

Copy
2000 0 0

题解:与找零钱类似

#include <iostream>
#include <set>
using namespace std;
int main()
{
int n,Y;
while(cin>>n>>Y){
Y/=;
if(n*<Y||n>Y){
cout<<-<<" "<<-<<" "<<-<<endl;
continue;
}
int flag=;
for(int i=n;i>=;i--){
for(int j=n-i;j>=;j--){
for(int l=n-i-j;l>=;l--){
if((i+j+l==n)&&(i*+j*+l==Y)){
cout<<i<<" "<<j<<" "<<l<<endl;
flag=;
break;
}
}
if(flag) break;
}
if(flag) break;
}
if(!flag) cout<<-<<" "<<-<<" "<<-<<endl;
}
return ;
}

D - Katana Thrower

题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_d

Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, Katana N, and can perform the following two kinds of attacks in any order:

  • Wield one of the katana you have. When you wield Katana i (1≤iN), the monster receives ai points of damage. The same katana can be wielded any number of times.
  • Throw one of the katana you have. When you throw Katana i (1≤iN) at the monster, it receives bi points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.

The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Constraints

  • 1≤N≤105
  • 1≤H≤109
  • 1≤aibi≤109
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N H
a1 b1
:
aN bN

Output

Print the minimum total number of attacks required to vanish the monster.


Sample Input 1

Copy
1 10
3 5

Sample Output 1

Copy
3

You have one katana. Wielding it deals 3 points of damage, and throwing it deals 5 points of damage. By wielding it twice and then throwing it, you will deal 3+3+5=11 points of damage in a total of three attacks, vanishing the monster.


Sample Input 2

Copy
2 10
3 5
2 6

Sample Output 2

Copy
2

In addition to the katana above, you also have another katana. Wielding it deals 2 points of damage, and throwing it deals 6 points of damage. By throwing both katana, you will deal 5+6=11 points of damage in two attacks, vanishing the monster.


Sample Input 3

Copy
4 1000000000
1 1
1 10000000
1 30000000
1 99999999

Sample Output 3

Copy
860000004

Sample Input 4

Copy
5 500
35 44
28 83
46 62
31 79
40 43

Sample Output 4

Copy
9

题解:找出a中最大的maxn 然后依次扔出b中比a大的 如果还有多 全用a中最大的maxn
 #include<bits/stdc++.h>
using namespace std;
long long a[],b[];
bool cmp(int x,int y)
{
return x>y;
}
int main()
{
long long n,h;
while(cin>>n>>h){
for(int i=;i<n;i++){
cin>>a[i]>>b[i];
}
sort(a,a+n,cmp);
long long maxn=a[],s=;
sort(b,b+n,cmp);
for(int i=;i<n;i++){
if(b[i]>=maxn&&h>=maxn){
h-=b[i];
s++;
}
}
if(h>=){
s+=h/maxn;
if(h%maxn!=) s++;
} cout<<s<<endl;
}
return ;
}

AtCoder Beginner Contest 085(ABCD)的更多相关文章

  1. AtCoder Beginner Contest 086 (ABCD)

    A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_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 084(AB)

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

  4. AtCoder Beginner Contest 083 (AB)

    A - Libra 题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_a Time limit : 2sec / Memory limit : 2 ...

  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 121D(异或公式)

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

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

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

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

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

随机推荐

  1. OC常用控件封装

    #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface CreateUI : NSObject ...

  2. MySQL数据库的权限问题操作及基本增删改查操作

    前面我们讲了mysql的基本内容,现在我们详细的了解一下mysql中的具体操作. what's the SQl SQL(Structured Query Language 即结构化查询语言) SQL语 ...

  3. AxMIMS系统开发环境搭建

    系统环境:Windows10, VS2013, Qt5.6.2 64bit 1.CloudCompare2.8.1编译 (shapefilelib1.3,geos3.6.1) 2.PCL-1.8.0- ...

  4. linux命令注解

    参考: Linux命令实例练习 -- 实验楼 太懒,就不全抄了,把自己觉得有坑的地方记录下来. ls ls命令的20个实用范例 -- linux.cn 常用参数 参数 描述 -a –all 列出目录下 ...

  5. PHP中的回调函数

    回调函数是指调用函数的时候将另一个函数作为参数传递到调用的函数中,而不是传递一个普通的变量作为参数 使用回调函数是为了可以将一段自己定义的功能传到函数内部使用 声明回调函数的方法 变量函数声明 1 2 ...

  6. [LeetCode] 613. Shortest Distance in a Line_Easy tag: SQL

    Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. Writ ...

  7. vmware 下linux 共享文件夹消失

    今天遇到了vmware下linux和宿主win7系统共享文件,突然在linux下消失的问题 环境:vmware10.0.0下装了centos, 主机系统是win7. 背景:事情的初衷是想让win7 下 ...

  8. windows go dll 框架

    乘着还没有添加商业功能之前,先给大家把福利分享了 希望有需要的朋友能够用的上 这个框架是在用windows平台,GO做的http/https服务,调用dll现有的库接口实现特定功能的大框架 //dll ...

  9. 深入解密.NET(GC垃圾回收)

    值类型与引用类型 值类型(Value Type),值类型实例通常分配在线程的堆栈(stack)上,并且不包含任何指向实例数据的指针,因为变量本身就包含了其实例数据 C#的所有值类型均隐式派生自Syst ...

  10. 多模块项目提示“Module ** must not contain source root **. The root already belongs to module **”的解决办法

    从Project Structure里添加模块,完了点击Apply时弹出提示: Module "paycode"must not contain source root " ...