周测题目讲解6-11
5k_sync_closer · · 个人记录
这次虽然名义上是别的校区的周测,但5个AK的3个在我们这边
这说明了什么为了找回一些自信心,我也来混了个AK拿了262ms的第一
估计第二都不认识我
老崔说可以写教程,虽然没啥可写的
T1 动态分值计算
这题直接套公式即可
注意double和int的使用,还有前三的额外加成
#include <cstdio>
using namespace std;
double a, n, c;int k;
int main()
{
scanf("%lf%lf%d", &a, &n, &k);
c = a / (n < 25 ? n : 25);
switch(k)
{
case 1: c += a * 0.05;break;
case 2: c += a * 0.03;break;
case 3: c += a * 0.01;break;
}
printf("%.2lf", c);
return 0;
}
全定义成double,类型转换可能会出一些奇奇怪怪的错误
像这样定义,就不需要转换类型,可以避免出锅
T2 接送新生
这题没有INT_MAX%把握千万别优化,老老实实
#include <cstdio>
using namespace std;
int a, b, c, x, y;long long ans;
int main()
{
scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
while(a >= c)
a -= c, ans += x;
if(a) b -= c - a, a = 0, ans += x;
while(b > 0)
b -= c, ans += x < y ? x : y;
printf("%lld", ans);
return 0;
}
模拟代码不需要讲吧
T3 密码强度
string模拟即可
#include <iostream>
#include <string>
using namespace std;
string s;bool a, b, c;
int main()
{
cin >> s;
if(s.length() < 6) {cout << "no";return 0;}
for(int i = 0;i < s.length();++i)
{
if(s[i] >= 'a' && s[i] <= 'z') a = 1;
if(s[i] >= 'A' && s[i] <= 'Z') b = 1;
if(s[i] >= '0' && s[i] <= '9') c = 1;
}
if(a && b && c) cout << "yes";
else cout << "no";
return 0;
}
T4 皆传养成计划
这个T4出在这里水的不行,直接模拟即可
#include <cstdio>
using namespace std;
int n, x, d, ans;
int main()
{
scanf("%d%d", &n, &x);
for(int i = 0;i < n;++i)
{
scanf("%d", &d);
if(d <= x) ++ans;
}
if(ans >= 30) printf("YES!");
else printf("NO!!!");
return 0;
}
总结
这次考的周测其实都是我们做过的题诶嘿嘿
都是模拟大水题,但这里要说一句
模拟能过的题千万别写数论!!!