今天中石的比赛打的很拉跨
加油叭
问题 A: 小李数星星
题目描述
小李在农村长大,那时候大家喜欢晚饭过后在院子里纳凉,听不懂大人在说什么的小李喜欢抬头看天空,尤其是夏天的夜晚,天上的星星又多又亮。
长大后小李进城打工,每当想家的时他还是喜欢抬头看看天,寻找另一边故乡的记忆。
可是大城市里空气质量太差了,雾霾天气横行,天上能看到的星星也越来越少了。
小李每次用一个正方形去覆盖自己所能看到的星星,随着日子的推移,这个正方形越来越小了,悲伤的小李希望你能告诉他这个正方形的面积。为了让问题变得简单,小李每次只会使用水平放置的正方形来覆盖(不会旋转),具体参照样例解释。
输入
第一行一个整数n,表示星星的数量。
接下来共n行,每行2个正整数(a,b),表示该星星到X轴距离为b,到Y轴距离为a,这些星星只会位于X轴的上方,Y轴的右方。
输入数据保证存在一个合法的正方形 (面积非零)去覆盖这些星星
输出
一个整数,表示能覆盖所有星星的最小正方形的面积。
样例输入 Copy
3 1 1 2 1 2 2
样例输出 Copy
1
提示
100%的数据,3<=n<=1000, 1<=x<=100000, 1<=y<=100000
注意 是正方形 而且全在一点的话面积也不能为0 剩下就没什么了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
long long n;
cin>>n;
long long x,y;
long long max = 0;
long long may = 0;
long long mix = 1e9;
long long miy = 1e9;
while(n--)
{
cin>>x>>y;
if(x > max) max = x;
if(x < mix) mix = x;
if(y > may) may = y;
if(y < miy) miy = y;
}
long long ans;
long long ax = max - mix;
long long ay = may - miy;
if(ax > ay)
{
ans = ax * ax;
}
else if(ax <= ay)
{
ans = ay * ay;
}
if(!ax && !ay)
{
ans = 1;
}
cout<<ans<<endl;
return 0;
}
问题 B: 小李打台球
题目描述
在异乡打拼的小李同志迷上了一款叫斯诺克的台球游戏,而且随着练习的深入,他总是能在某些神奇的时候开启外挂模式,此时小李指哪打哪,直至无球可打。现在小李想让你帮他计算下当他开启外挂模式的时候最多可以取得多少分数。
注意:台面上的球数经常会异于传统斯诺克。
斯诺克比赛的基本规则如下:
一、彩球共分8种颜色,红(1分)、黄(2分)、绿(3分)、棕(4分)、蓝(5分)、粉(6分)、黑(7分)、白(主球,控制白球大其余球)。
二、当台面上有红球的时候你必须先击打一个红球,然后只能击打一个彩球(不包括红球),此时落袋的彩球将会被放回桌面,一直重复该过程。
三、当打完规则二的彩球(不包括红球)发现已经没有红球时,按彩球的分值从高到低将其依次击入袋中。
输入
输入仅有一行,共7个用空格隔开的整数,分别为当前台面上红、黄、绿、棕、蓝、粉、黑球的数目。
输出
输出仅有一行,共1个整数,表示小李可以得到的最高得分。
样例输入 Copy
2 0 1 0 3 0 2
样例输出 Copy
48
提示
台面上共有红球2个、绿球1个、蓝球3个、黑球2个,获得最高分的打法是红-黑-红-黑-绿-蓝-蓝-蓝-黑-黑,共可以获得48分。
保证最后得分不超过2^31-1.
注意只有红球的情况
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
long long a[10];
int vis = 0;
for(int i = 1; i <= 7; i++)
{
cin>>a[i];
if(a[i]) vis = i;
}
long long ans = 0;
for(int i = 1; i <= a[1]; i++)
{
if(vis > 1) ans = ans + 1 + vis;
else if(vis == 1)
{
ans++;
break;
}
}
for(int i = 2; i <= 7; i++)
{
ans += (i * a[i]);
}
cout<<ans<<endl;
return 0;
}
请小伙伴们对自己AC的题目进行标记,注意每人只能标记一次!不知道的不要标记,恶意标记者将回收账号!!!
问题 E: 数列计算III
题目描述
有一组序列的数是:1、2、9、33、126、477,……,请同学们认真观察数值的规律。现要求:指定项数为任意的N项,计算:
1)第N项的数据;
2)输出前N项数据的和。
输入
只有一行,包含1个整数N(其中3<=N<=15)为这个序列的项数。
输出
共有二行:
第一行为这个序列第N项的数据;
第二行为这个序列前N项的数据和。
样例输入 Copy
6
样例输出 Copy
477 648
GPLv2 licensed by HUSTOJ 2021
找规律的题 发现所有的数都能整除三 然后慢慢就发现规律了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
long long a[20];
a[1] = 1;
a[2] = 2;
for(int i = 3; i <= 15; i++)
{
if(i % 2)
{
a[i] = a[i - 1] + a[i - 2];
}
else
{
a[i] = a[i - 1] * 3 + a[i - 2];
}
}
for(int i = 3; i <= 15; i += 2)
{
int temp = i / 2;
a[i] = a[i] * pow(3, temp);
a[i + 1] = a[i + 1] * pow(3, temp);
}
int n;
cin>>n;
cout<<a[n]<<endl;
long long ans = 0;
for(int i = 1; i <= n; i++)
{
ans += a[i];
}
cout<<ans<<endl;
return 0;
}
问题 F: 分数段统计
题目描述
小红所在的班级进行了数学考试,老师请小红同学帮忙进行名次排序和各分数段的人数统计工作。现要求如下:将N名同学的考试成绩放在A数组中,各分数段的人数存到B数组中:成绩为100的人数存到B(1)中,成绩为90到99的人数存到B(2)中,成绩为80到89的人数存到B(3)中,成绩为70到79的人数存到B(4)中,成绩为60到69的人数存到B(5)中,成绩为60分以下的人数存到B(6)中。
输入
共有二行:
第一行:为小红所在班级的人数N(其中1<=N<=30);
第二行:为N个用1个空格隔开的数学分数(其中分数为整数,0≤分数≤100)。
输出
共有若干行:
前N行:每行一个整数是从高到低排序的数学分数;
最后一行:6个整数,表示存放到数组B(1)--B(6)中各分数段的人数(各数据之间以1个空格为间隔)。
样例输入 Copy
10 93 85 77 68 59 100 43 94 75 82
样例输出 Copy
100 94 93 85 82 77 75 68 59 43 1 2 2 2 1 2
水题
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
int n;
cin>>n;
int a[35] = {0};
int b[10] = {0};
for(int i = 1; i <= n; i++)
{
cin>>a[i];
if(a[i] == 100) b[1]++;
if(a[i] >= 90 && a[i] <= 99) b[2]++;
if(a[i] >= 80 && a[i] <= 89) b[3]++;
if(a[i] >= 70 && a[i] <= 79) b[4]++;
if(a[i] >= 60 && a[i] <= 69) b[5]++;
if(a[i] < 60) b[6]++;
}
sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= n; i++)
{
cout<<a[i]<<endl;
}
for(int i = 1; i <= 6; i++)
{
cout<<b[i];
if(i != 6) cout<<' ';
else cout<<endl;
}
return 0;
}
问题 G: 求素数II
题目描述
在三位自然数中有这样一些特点的数:
(1)它们是素数;
(2)它们中满足:十位数字是偶数,个位数字为3,
如:223,283,383,443,463…….等。
求出在三位自然数的任意区间M ~N内所有满足上述条件的素数,并统计个数。
输入
只有一行,包含两个用空格隔开的任意自然数M和N(其中100<=M<N<=999)。
输出
共有若干行:前若干行每行一个数,为满足条件的素数;
样例输入 Copy
200 400
样例输出 Copy
223 263 283 383
水题
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
bool cmp(int a, int b)
{
return a > b;
}
bool check(int i)
{
int a = (i % 100) / 10;
int b = i % 10;
if(a % 2 == 0 && b == 3) return true;
return false;
}
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
int n,m;
cin>>n>>m;
bool a[1005] = {0};
for(int i = 2; i <= 1000; i++)
{
if(!a[i])
{
for(int j = 2 * i; j <= 1000; j += i)
{
a[j] = 1;
}
}
}
for(int i = n; i <= m; i++)
{
if(!a[i] && check(i))
{
cout<<i<<endl;
}
}
return 0;
}
问题 I: 海淀字符串II
题目描述
从键盘输入一个长度大于10的字符串,现要求:将字符串中的所有大小写字母都改写成该字母的下一个字母。如:最后一个小写字母z改写成字母a;最后一个大写字母Z改写成A,其他字符依照原有顺序不变。
输入
只有一行,包含1个任意的字符串(其长度L>10)
输出
只有一行,即为满足条件的字符串。
样例输入 Copy
ABCDZ123abcdefz
样例输出 Copy
BCDEA123bcdefga
水题 看标题应该是海淀区的小朋友们写的无疑了 可怜代某连小孩子都打不过
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
string s;
cin>>s;
long long sl = s.size();
for(int i = 0; i <= sl - 1; i++)
{
if(s[i] == 'z')
{
s[i] = 'a';
}
else if(s[i] == 'Z')
{
s[i] = 'A';
}
else if(s[i] >= 'a' && s[i] <= 'y')
{
s[i] = s[i] + 1;
}
else if(s[i] >= 'A' && s[i] <= 'Y')
{
s[i] = s[i] + 1;
}
}
cout<<s<<endl;
return 0;
}
问题 J: 评奖II
题目描述
小明同学所在的班级共有N名同学,期末考试时进行了数学、语文、英语、地理四门功课的测试。现要将班里总分最高的同学评为“学习小状元”。
如3名学生,4门课程的成绩如下:
请同学们帮助计算:
(1)每位同学的总分是多少?
(2)找出总分最高的那位同学。
(3)找出所有成绩中最高的分数和最小的分数。
输入
共有2N+1行:
第一行:有一个整数N,表示有N名同学(已知 )。
后2N行:每两行代表一个人的信息记录:
包括学生的姓名及4门功课的分数:其中分数为整数,每个分数互不相同(不需判断),各数据之间空1个格。
输出
共有N+2行:
前N行:每行一个数据是每位同学的总分;
第N+1行:是总分最高的那位同学的姓名;
第N+2行:是所有成绩中最高的分数和最小的分数(数据之间空1格)
样例输入 Copy
3 hong 98 90 87 74 ming 96 92 85 97 zhang 95 78 56 91
样例输出 Copy
349 370 320 ming 98 56
思路很简单的一道题 但我还是不知道为什么会wa那么多发
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false),cin.tie(NULL);
long long N;
cin>>N;
if(!N)
{
cout<<endl;
cout<<' '<<endl;
return 0;
}
else
{
string ans;
long long zmax;
long long h;
long long l;
long long a,b,c,d;
string n;
long long sum;
for(int i = 1; i <= N; i++)
{
cin>>n;
cin>>a>>b>>c>>d;
sum = a + b + c + d;
cout<<sum<<endl;
if(i == 1)
{
zmax = sum;
h = a;
l = a;
ans = n;
}
if(sum > zmax)
{
zmax = sum;
ans = n;
}
if(a > h) h = a;
if(b > h) h = b;
if(c > h) h = c;
if(d > h) h = d;
if(a < l) l = a;
if(b < l) l = b;
if(c < l) l = c;
if(d < l) l = d;
}
cout<<ans<<endl;
cout<<h<<' '<<l<<endl;
return 0;
}
}