天津新东方双周赛 #3
提高组 前 6 名
T1 题解
#include <bits/stdc++.h>
using namespace std;
bool fun(int t){
if(t<2) return false;
if(t==2) return true;
for(int i=3;i*i<=t;i++)
if(t%i==0) return false;
return true;
}//函数:判断素数
int main(){
int n,cnt=0;
cin >> n;
for(int i=7;i<=n;i++){
if(i%10==7 && fun(i)) cnt++;
}
cout << cnt;
}
T2 题解
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[1000];
for(int i=0;i<n;i++) cin >> a[i];
int maxx=-1;
for(int i=0;i<n;i++){
int cnt=a[i]+a[i+1]+a[i+2];//枚举
if(cnt>maxx) maxx=cnt;//打擂台的方式去找最大值
}
cout << maxx;
}
普及组 前 6 名
T1 题解
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
cout << n - 1;
}
T2 题解
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin >> n >> m;
int cnt = 0;
for(int i = n;i <= m;i++)
{
int sum = 0;
int t = i;
while(t)
{
sum += t % 10;
t /= 10;
}
if(sum == 8)
cnt++;
//cout << sum << " ";
}
cout << cnt;
}
T3 题解
#include <bits/stdc++.h>
using namespace std;
int main()
{
int h,r;
cin >> h >> r;
cout << ceil(20000 / (h * r * r * 3.14));//别忘了转换单位
}
T4 题解
#include <bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,e,f,g,h,i,j;
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i >> j;
double maxx = max({a,b,c,d,e,f,g,h,i,j});
double minn = min({a,b,c,d,e,f,g,h,i,j});
double sum = a + b + c + d + e + f + g + h + i + j;
cout << (sum - maxx - minn) / 8;
}