AtCoder Beginner Contest 073 ABC C++&&Python3

A - September 9


Time Limit: 2 sec / Memory Limit: 256 MB

Score : 100100 points

Problem Statement

It is September 99 in Japan now.

You are given a two-digit integer NN. Answer the question: Is 99 contained in the decimal notation of NN?

Constraints

  • 10N9910≤N≤99

Input

Input is given from Standard Input in the following format:

NN

Output

If 99 is contained in the decimal notation of NN, print Yes; if not, print No.


Sample Input 1 Copy

Copy
29

Sample Output 1 Copy

Copy
Yes

The one's digit of 2929 is 99.


Sample Input 2 Copy

Copy
72

Sample Output 2 Copy

Copy
No

7272 does not contain 99.


Sample Input 3 Copy

Copy
91

Sample Output 3 Copy

Copy
Yes

判断有没有9

C++:

#include<bits/stdc++.h>
using namespace std;
int main(){
	char cha,chb;
	cin>>cha>>chb;
	if(cha=='9') cout<<"Yes"<<endl;
	else if(chb=='9') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Python:

print("Yes" if '9' in input() else "No")


B - Theater


Time Limit: 2 sec / Memory Limit: 256 MB

Score : 200200 points

Problem Statement

Joisino is working as a receptionist at a theater.

The theater has 100000100000 seats, numbered from 11 to 100000100000.

According to her memo, NN groups of audiences have come so far, and the ii-th group occupies the consecutive seats from Seat lili to Seat riri (inclusive).

How many people are sitting at the theater now?

Constraints

  • 1N10001≤N≤1000
  • 1liri1000001≤li≤ri≤100000
  • No seat is occupied by more than one person.
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN
l1l1 r1r1
::
lNlN rNrN

Output

Print the number of people sitting at the theater.


Sample Input 1 Copy

Copy
1
24 30

Sample Output 1 Copy

Copy
7

There are 77 people, sitting at Seat 24,25,26,27,28,2924,25,26,27,28,29 and 3030.


Sample Input 2 Copy

Copy
2
6 8
3 3

Sample Output 2 Copy

Copy
4

C++:

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b;
	int sum=0;
	while(n--){
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<endl;
}

Python:

n=int(input())
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=b-a+1
print(ans)



C - Write and Erase

Time Limit: 2 sec / Memory Limit: 256 MB

Score : 300300 points

Problem Statement

You are playing the following game with Joisino.

  • Initially, you have a blank sheet of paper.
  • Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated NN times.
  • Then, you are asked a question: How many numbers are written on the sheet now?

The numbers announced by Joisino are given as A1,...,ANA1,...,AN in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Constraints

  • 1N1000001≤N≤100000
  • 1Ai1000000000(=109)1≤Ai≤1000000000(=109)
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN
A1A1
::
ANAN

Output

Print how many numbers will be written on the sheet at the end of the game.


Sample Input 1 Copy

Copy
3
6
2
6

Sample Output 1 Copy

Copy
1

The game proceeds as follows:

  • 66 is not written on the sheet, so write 66.

  • 22 is not written on the sheet, so write 22.

  • 66 is written on the sheet, so erase 66.

Thus, the sheet contains only 22 in the end. The answer is 11.


Sample Input 2 Copy

Copy
4
2
5
5
2

Sample Output 2 Copy

Copy
0

It is possible that no number is written on the sheet in the end.


Sample Input 3 Copy

Copy
6
12
22
16
22
18
12

Sample Output 3 Copy

Copy
2
C++:
#include<iostream>
#include<set>
using namespace std;
set<int> st;
set<int>::iterator it;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		it=st.find(a);
		if(it!=st.end()) st.erase(a);
		else st.insert(a);
	}
	int ans=0;
	for(int i=0;i<st.size();i++) ans++;
	cout<<ans<<endl;
}
Python:
n=int(input())
se=set()
for i in range(n):
	a=int(input())
	if a in se:
		se.remove(a)
	else:
		se.add(a)
print(len(se))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值