0
点赞
收藏
分享

微信扫一扫

Codeforces上通过数超过5W人的题

yeamy 2023-02-08 阅读 49


Codeforces上通过数超过5W人的题

共32题:1000分4题,800分28题。

编号

题号

题名

分数

通过数

1

4A

Watermelon

800

x193501

2

71A

Way Too Long Words

800

x139875

3

1A

Theatre Square

1000

x129840

4

231A

Team

800

x110349

5

158A

Next Round

800

x100668

6

50A

Domino piling

800

x91572

7

118A

String Task

1000

x91186

8

282A

Bit++

800

x88410

9

112A

Petya and Strings

800

x86268

10

263A

Beautiful Matrix

800

x85665

11

339A

Helpful Maths

800

x81033

12

281A

Word Capitalization

800

x78025

13

266A

Stones on the Table

800

x73870

14

236A

Boy or Girl

800

x71994

15

96A

Football

900

x70703

16

69A

Young Physicist

1000

x65649

17

546A

Soldier and Bananas

800

x64185

18

791A

Bear and Big Brother

800

x63551

19

977A

Wrong Subtraction

800

x60449

20

116A

Tram

800

x59523

21

58A

Chat room

1000

x59134

22

617A

Elephant

800

x59119

23

122A

Lucky Division

1000

x57871

24

59A

Word

800

x56614

25

266B

Queue at the School

800

x55940

26

160A

Twins

900

x55193

27

110A

Nearly Lucky Number

800

x54926

28

41A

Translation

800

x53735

29

734A

Anton and Danik

800

x53136

30

133A

HQ9+

900

x51033

31

271A

Beautiful Year

800

x50871

32

467A

George and Accommodation

800

x50310

4A. Watermelon

//判断w能否被分为两个偶数相加
#include<bits/stdc++.h>
using namespace std;
int main(){
int w; cin>>w;
if(w%2==0 && w>2){
cout<<"YES\n";
}else{
cout<<"NO\n";
}
return 0;
}

71A. Way Too Long Words

//n个字符串,输出首位字母和长度
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
for(int i = 1; i <= n; i++){
string s; cin>>s;
if(s.size()>10)cout<<s[0]<<s.size()-2<<s[s.size()-1]<<"\n";
else cout<<s<<"\n";
}
return 0;
}

1A. Theatre Square

//用大小为a*a的石板覆盖m*n的地表,求最少数量
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;//WA at 9
int main(){
LL n, m, a;
cin>>n>>m>>a;
LL x = n%a==0 ? n/a : n/a+1;
LL y = m%a==0 ? m/a : m/a+1;
cout<<x*y<<"\n";//1e9*1e9>1e9
return 0;
}

231A. Team

//3个人,n个问题,输出有几个问题三人中有2人给出了解
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
int cnt = 0;
for(int i = 1; i <= n; i++){
int a, b, c; cin>>a>>b>>c;
if(a+b+c>=2)cnt++;
}
cout<<cnt<<"\n";
return 0;
}

158A. Next Round

//n个人的成绩降序,大于等于第k名的进决赛,求多少人进
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, k; cin>>n>>k;
int cnt = 0, kk;
for(int i = 1; i <= n; i++){
int x; cin>>x;
if(i==k)kk=x;
if(x<=0)continue;

if(i<=k){
cnt++;
}else{
if(x==kk)cnt++;
else break;
}
}
cout<<cnt<<"\n";
return 0;
}

50A. Domino piling

//在n*m的矩阵放置尽可能多2*1的米诺骨牌
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin>>n>>m;
int x = n/2, y = m/2;
int cnt = x*y*2;
if(n%2==1)cnt += m/2;
if(m%2==1)cnt += n/2;
cout<<cnt<<"\n";
return 0;
}

118A. String Task

//输入一个字符串,删掉元音,输出符号.+小写字母
#include<bits/stdc++.h>
using namespace std;
int main(){
string s; cin>>s;
for(int i = 0; i < s.size(); i++){
s[i] = tolower(s[i]);
if(s[i]=='a'||s[i]=='o'||s[i]=='y'||s[i]=='e'||s[i]=='u'||s[i]=='i')continue;
else cout<<"."<<s[i];
}
return 0;
}

282A. Bit++

//x初始为0,执行n次--或++的结果
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
LL x = 0;
int n; cin>>n;
for(int i = 0; i < n; i++){
string s; cin>>s;
if(s[0]=='+'||s[2]=='+')x++;
else x--;
}
cout<<x<<"\n";
return 0;
}

112A. Petya and Strings

//比较两个长度相同的字符串字典序大小,不计大小写
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string a, b; cin>>a>>b;
for(int i = 0; i < a.size(); i++){
a[i] = tolower(a[i]);
b[i] = tolower(b[i]);
}
if(a==b)cout<<0;
else if(a<b)cout<<-1;
else cout<<1;
return 0;
}

263A. Beautiful Matrix

//一个5*5的矩阵,1个1剩余是0,通过交换相邻把1交换到中间的次数
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int dx, dy;
for(int i = 1; i <= 5; i++){
for(int j = 1; j <= 5; j++){
int x; cin>>x;
if(x==1){
dx = i, dy = j;
}
}
}
cout<<abs(3-dx)+abs(3-dy);
return 0;
}

339A. Helpful Maths

//给出一个竖式字符串,重新排序。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
sort(s.begin(), s.end());
for(int i = 0; i < s.size(); i++){
if(s[i]=='+')continue;
cout<<s[i];
if(i!=s.size()-1)cout<<"+";
}
return 0;
}

281A. Word Capitalization

//给出一个字符串,大写第一个字母
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
s[0] = toupper(s[0]);
cout<<s;
return 0;
}

266A. Stones on the Table

//给出一个RGB字符串,取走n个,使相邻的不同
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n; cin>>n;
string s; cin>>s;
int cnt = 0, l = 0;
for(int i = 1; i < s.size(); i++){
if(s[i]==s[l]){
cnt++;
continue;
}else{
l = i;
}
}
cout<<cnt<<"\n";
return 0;
}

236A. Boy or Girl

//给出一个字符串,判断不同字符数量个数
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
set<char>se;
for(int i = 0; i < s.size(); i++){
se.insert(s[i]);
}
if(se.size()%2==0)cout<<"CHAT WITH HER!";
else cout<<"IGNORE HIM!";
return 0;
}

96A. Football

//给出一个字符串,判断有没有7个连续的0或1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
int ok = 0, cnt = 1;
for(int i = 1; i < s.size(); i++){
if(s[i]==s[i-1])cnt++;
else{
if(cnt>=7)ok = 1;
cnt = 1;
}
}
if(cnt>=7)ok = 1;//wa at 4
if(ok==1)cout<<"YES\n";
else cout<<"NO";
return 0;
}

69A. Young Physicist

//给出n个3维坐标,判断其矢量和是否为0,直接累加。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n, a=0, b=0, c=0;
cin>>n;
for(int i = 0; i < n; i++){
int x, y, z; cin>>x>>y>>z;
a += x; b += y; c += z;
}
if(a==0 && b==0 && c==0){
cout<<"YES\n";
}else{
cout<<"NO";
}
return 0;
}

546A. Soldier and Bananas

//费用为s=k+2k+3k+..wk,求n和s的差值
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
LL n, k, w; cin>>k>>n>>w;
LL s = 0;
for(int i = 1; i <= w; i++){
s += i*k;
}
if(s>n)cout<<s-n;
else cout<<0;
return 0;
}

791A. Bear and Big Brother

//体重a和b,每年a=3a,b=2b,求什么时候a>b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
LL a, b;
cin>>a>>b;
int cnt = 0;
while(a<=b){
cnt++;
a *= 3;
b *= 2;
}
cout<<cnt<<"\n";
return 0;
}

977A. Wrong Subtraction

//将一个整数n减k次,末位非零减一,为零就去掉。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n, k; cin>>n>>k;
for(int i = 0; i < k; i++){
if(n%10!=0)n--;
else {
n = n/10;
}
}
cout<<n<<"\n";
return 0;
}

116A. Tram

//电车停n次,下来ai个上来bi个,求最小可行容量
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n; cin>>n;
int mi = 0, pe = 0;
for(int i = 0; i < n; i++){
int a, b; cin>>a>>b;
pe -= a; pe += b;
mi = max(mi, pe);
}
cout<<mi<<"\n";
return 0;
}

58A. Chat room

//给出一个字符串,判断是否包含hello
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
string t = "hello"; int cur =0;
for(int i = 0; i < s.size(); i++){
if(s[i]==t[cur])cur++;
}
if(cur>=5)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

617A. Elephant

//从原点出发,每次1-5步,最少几次恰好到x
//当前f[x],从f[i-1]~f[i-5]转移而来,每次取最小的+1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int f[1000010];
int main(){
int x; cin>>x;
f[1] = f[2] = f[3] = f[4] = f[5] = 1;
for(int i = 6; i <= x; i++){
f[i] = 1e9;
f[i] = min(f[i],f[i-1]);
f[i] = min(f[i],f[i-2]);
f[i] = min(f[i],f[i-3]);
f[i] = min(f[i],f[i-4]);
f[i] = min(f[i],f[i-5]);
f[i]++;
}
cout<<f[x]<<"\n";
return 0;
}

122A. Lucky Division

//判断一个数字是否仅由47构成或者可以被47构成的数字整除.
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int di[]={4,7,44,77,47,444,777,447,474,744,774,747,477};
int main(){
int x; cin>>x;
int ok = 0;
for(int i = 0; i < 13; i++){
if(x==di[i]||x%di[i]==0){
ok = 1;
}
}
if(ok==1)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

59A. Word

//给出一个字符串,修改尽可能少的字符使其全大写或全小写
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
int low = 0;
for(int i = 0; i < s.size(); i++){
if(islower(s[i]))low++;
}
if(low>=s.size()-low){
for(int i = 0; i < s.size(); i++){
s[i] = tolower(s[i]);
}
cout<<s;
}else{
for(int i = 0; i < s.size(); i++){
s[i] = toupper(s[i]);
}
cout<<s;
}
return 0;
}

266B. Queue at the School

//给出一个GB字符串,每秒扫一遍,把BG换成GB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n, t; cin>>n>>t;
string s; cin>>s;
for(int i = 0; i < t; i++){
int cur = 0;
while(s.find("BG",cur)!=string::npos){
cur = s.find("BG",cur);
s[cur] = 'G';
s[cur+1] = 'B';
cur = cur+2;
//cout<<cur<<" "<<s<<"\n";
}
}
cout<<s<<"\n";
return 0;
}

160A. Twins

//n枚硬币,从中选出最少个数使其总价值大于总和的一半
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[110];
int main(){
int n; cin>>n;
int sum = 0;
for(int i = 1; i <= n; i++){
cin>>a[i]; sum+=a[i];
}
sort(a+1,a+n+1);
int now = 0, cnt = 0;
for(int i = n; i >= 1; i--){
if(2*now>sum){
break;
}else{
now += a[i];
cnt++;
}
}
cout<<cnt<<"\n";
return 0;
}

110A. Nearly Lucky Number

//判断一个数字中4和7的个数,是否只由4和7构成.
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s; cin>>s;
int cnt = 0;
for(int i = 0; i < s.size(); i++){
if(s[i]=='4'||s[i]=='7')cnt++;
}

if(cnt==0){
cout<<"NO\n"; return 0;
}
int ok = 1;
while(cnt){
if(cnt%10==4||cnt%10==7){
cnt /= 10; continue;
}else{
ok = 0; break;
}
}

if(ok==1)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

41A. Translation

//判断字符串t是否是s的取反
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
string s, t; cin>>s>>t;
reverse(s.begin(),s.end());

if(s==t)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

734A. Anton and Danik

//输入一个AD字符串, 统计A和D谁多
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n; cin>>n;
string s; cin>>s;
int a = 0, d = 0;
for(int i = 0; i < s.size(); i++){
if(s[i]=='A')a++;
else d++;
}

if(a==d)cout<<"Friendship\n";
else if(a>d)cout<<"Anton\n";
else cout<<"Danik";
return 0;
}

133A. HQ9+

//判断一个字符串是否包含HQ9+
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int ok = 0;
string s; cin>>s;
for(int i = 0; i < s.size(); i++){
if(s[i]=='H'||s[i]=='Q'||s[i]=='9')ok = 1;
}
if(ok==1)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

271A. Beautiful Year

//找出比给定年份大的第一个四位数字都不同的年份
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n; cin>>n; n++;
while(1){
int g=n%10, s=n/10%10, b = n/100%10, q = n/1000;
int z[15] = {0};
z[g] = z[s] = z[b] = z[q] = 1;
int cnt = 0;
for(int i = 0; i <= 9; i++)
if(z[i]==1)cnt++;
if(cnt==4){
cout<<n;
return 0;
}
n++;
}
return 0;
}

467A. George and Accommodation

//n个房间的人数和大小,求能住两个人的房间个数
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int n; cin>>n;
int cnt = 0;
for(int i = 0; i < n; i++){
int a, b; cin>>a>>b;
if(b-a>=2)cnt++;
}
cout<<cnt<<"\n";
return 0;
}


举报

相关推荐

0 条评论