7.28河西J2训练课day04-课后总结
比赛传送门
考试结果
T1
100分,用时30s
T2
100分,用时5min
T3
100分,用时10min
T4
0分,用时50min
T5
20分,用时20min
总分
320pts,rk1
题目解析
T1
Problem Description
已知三个正整数
请问满足上述条件的
Approach
穷举不会TLE
Code
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a,b,c;
cin>>a>>b>>c;
for(int i=2;i<=1000000;i++)
{
if(a%i==b%i&&b%i==c%i)
{
cout<<i;
return 0;
}
}
return 0;
}
Summary
水题实锤。
T2
Problem Description
国王将金币作为工资,发放给忠诚的骑士。第一天,骑士收到一枚金币;之后两天(第二天和第三天),每天收到两枚金币;之后三天(第四、五、六天),每天收到三枚金币;之后四天(第七、八、九、十天),每天收到四枚金币……;这种工资发放模式会一直这样延续下去:当连续 n 天每天收到
Approach
用一个变量记录天数,一个变量存储金币数量,两层循环,每次循环让day++即可。
Code
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int k,cnt=0,day=0;
cin>>k;
for(int i=1;;i++)
{
for(int j=1;j<=i;j++)
{
cnt+=i;
day++;
if(day==k)
{
cout<<cnt<<endl;
return 0;
}
}
}
return 0;
}
Summary
看深入浅出入门3循环结构即可,有原题。
T3
Problem Description
华华复盘自己的比赛,每一球的比分都会用一个字符表示。如果华华赢了一分,那么表示为W,反之则表示为L;比赛信息结束符为E。
Approach
其实这里就是读入有点麻烦,我们可以用一个字符数组读入。
我们知道 E一样跳出。
然后就遍历字符数组模拟每一轮即可,注意,最后需要输出一遍剩余比分,就算是0:0也要输出。
Code
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
char s[62505];
int i=0,h=0,d=0;
while(cin>>s[i])
{
if(i>=62500) return 0;
if(s[i]=='E') break;
i++;
}
int len=strlen(s);
int hh=0,ds=0;
for(int j=0;j<len;j++)
{
if(s[j]=='W') hh++;
if(s[j]=='L') ds++;
if((hh>=11||ds>=11)&&abs(hh-ds)>=2)
{
cout<<hh<<":"<<ds<<endl;
hh=0;ds=0;
}
}
cout<<hh<<":"<<ds<<endl<<endl;
hh=0;ds=0;
for(int j=0;j<len;j++)
{
if(s[j]=='W') hh++;
if(s[j]=='L') ds++;
if((hh>=21||ds>=21)&&abs(hh-ds)>=2)
{
cout<<hh<<":"<<ds<<endl;
hh=0;ds=0;
}
}
cout<<hh<<":"<<ds<<endl<<endl;
return 0;
}
Summary
这道题主要考的是另类的输入(不行了怎么这几天天天遇到不按常理输入的题目啊/(ㄒoㄒ)/~~)