1.总结
一共6道题,共得308分,具体如下表
古老的仪式 | 耳机电量 | 滑雪场的“鱼雷” | 谁赢了? | 数1的个数 | Bojack看哪吒2 |
---|---|---|---|---|---|
90 | 100 | 18 | 0 | 100 | 0 |
2.题目分析
T1 古老的仪式
这就是一个约瑟夫环的模拟题,无非就是根据题意让人出去,然后反反复复进行这一操作就好了。
考试时当成了要经过一些处理的约瑟夫环,于是就90pts含泪收场(悲
T2 耳机电量
肥肠煎蛋,不讲了。
#include <bits/stdc++.h>
#define int long long
#define N 1000+10
#define mod 1000000007
using namespace std;
signed main()
{
// freopen("P2880_1.in", "r", stdin);
// freopen("god.out", "w", stdout);ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n;cin>>n;int ans=(n/5)*10;n%=5;if(n!=0){ans+=n/0.5;}cout<<ans/60<<' '<<ans%60;return 0;
}
T3 滑雪场的“鱼雷”
本题最大的难点就是坐标的处理,处理完然后就是一个简单的追击和相遇问题了,两个人能撞上需要满足,两个人位置左右移动 1 个单位能撞上。这里需要注意,既然两个人都可以移动 1 个单位,那么其实就可以理解为,在小马 宽度信息 −2和 +2 的范围内,如果有别人,两个人就在宽度上会相遇,长度相遇的条件就是小马在某人后面,但是速度更快(他会撞到别人),或者小马在某个人前面,但是速度更慢(他会被别人撞到)。
然后就用代码进行答案的保存,输出的时候判重就好了。
#include <bits/stdc++.h>
#define int long long
#define N 1000+10
#define mod 1000000007
using namespace std;
int x, y, v, n, flag = 1;
int a[1010], b[1010], c[1010], cnt, ans[1010];
signed main()
{ios::sync_with_stdio(0);cin.tie(0);cin >> n;for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];cin >> x >> y >> v;for(int i = 1; i <= n; i++){if(max(0, b[i] - 2) <= y && y <= min(b[i] + 2, 40)){if((x > a[i] && v < c[i]) || (x < a[i] && v > c[i])){double t = 1.0 * (x - a[i]) / (c[i] - v);int wz = t * v + x;if(wz <= 3000) {ans[++cnt] = wz;flag = 0;}}}}if(flag == 1) cout << "safe\n";else {sort(ans + 1, ans + 1 + cnt);for(int i = 1; i <= cnt; i++){if(ans[i] != ans[i - 1]) {cout << ans[i] << '\n'; }}}return 0;
}
T4 谁赢了?
无脑if,end.
#include<bits/stdc++.h>
using namespace std;
int a[10], b[10], f1, f2;
void check1()
{if(a[1] == a[2] && a[2] == a[3] && a[3] == a[4]){f1 = 1;return;}if(a[2] == a[3] && a[3] == a[4] && a[4] == a[5]){f1 = 1;return;}if(a[1] == a[2] && a[3] == a[4] && a[4] == a[5]){f1 = 2;return;}if(a[1] == a[2] && a[2] == a[3] && a[4] == a[5]){f1 = 2;return;}if(a[1] + 1 == a[2] && a[2] + 1 == a[3] && a[3] + 1 == a[4] &&a[4] + 1 == a[5]){f1 = 3;return;}if(a[1] == a[2] && a[2] == a[3]){f1 = 4;return;}if(a[2] == a[3] && a[3] == a[4]){f1 = 4;return;}if(a[3] == a[4] && a[4] == a[5]){f1 = 4;return;}if(a[1] == a[2] && a[3] == a[4]){f1 = 5;return;}if(a[2] == a[3] && a[4] == a[5]){f1 = 5;return;}if(a[1] == a[2] || a[2] == a[3] || a[3] == a[4] || a[4] == a[5]){f1 = 6;return;}f1 = 7;
}
void check2()
{if(b[1] == b[2] && b[2] == b[3] && b[3] == b[4]){f2 = 1;return;}if(b[2] == b[3] && b[3] == b[4] && b[4] == b[5]){f2 = 1;return;}if(b[1] == b[2] && b[3] == b[4] && b[4] == b[5]){f2 = 2;return;}if(b[1] == b[2] && b[2] == b[3] && b[4] == b[5]){f2 = 2;return;}if(b[1] + 1 == b[2] && b[2] + 1 == b[3] && b[3] + 1 == b[4] &&b[4] + 1 == b[5]){f2 = 3;return;}if(b[1] == b[2] && b[2] == b[3]){f2 = 4;return;}if(b[2] == b[3] && b[3] == b[4]){f2 = 4;return;}if(b[3] == b[4] && b[4] == b[5]){f2 = 4;return;}if(b[1] == b[2] && b[3] == b[4]){f2 = 5;return;}if(b[2] == b[3] && b[4] == b[5]){f2 = 5;return;}if(b[1] == b[2] || b[2] == b[3] || b[3] == b[4] || b[4] == b[5]){f2 = 6;return;}f2 = 7;
}
int mbin()
{ios::sync_with_stdio(0);cin.tie(0);for(int i = 1; i <= 5; i++) cin >> a[i];for(int i = 1; i <= 5; i++) cin >> b[i];sort(a + 1, a + 1 + 5);sort(b + 1, b + 1 + 5);check1();check2();if(f1 < f2) cout << "TooY0ung\n";else if(f1 > f2) cout << "TooSimple\n";else{for(int i = 5; i >= 1; i--){if(a[i] > b[i]){cout << "TooY0ung\n";return 0;}if(a[i] < b[i]){cout << "TooSimple\n";return 0;}}}return 0;
}
T5 数1的个数
同T2,不讲了
#include <bits/stdc++.h>
#define int long long
#define N 1000+10
#define mod 1000000007
using namespace std;
signed main()
{int n;cin >> n;int count = 0; for (int i = 1; i <= n; ++i) {string number=to_string(i);for (char c : number) {if (c == '1') {count++; }}}cout<<count<<endl; return 0;
}
T6Bojack看哪吒2
这是个简单贪心,首先先保证把哪吒电影的时间段预留出来,然后优先看结束时间早的电影就行了。我认为时间转化为分钟更简单亿点。
#include<bits/stdc++.h>
using namespace std;
int n,ans,f;
struct st{string name;int a,b;
};
st p[105];
int time(string s){int w=((s[0]-'0')*10+(s[1]-'0'))*60+(s[3]-'0')*10+(s[4]-'0');return w;
}
bool cmp(st A,st B){if(A.b==B.b){return A.a>B.a;}return A.b<B.b;
}
int main(){cin>>n;for(int i=1;i<=n;i++){cin>>p[i].name;string s,e;cin>>s>>e;p[i].a=time(s);p[i].b=time(e);if(p[i].name=="nezha2"){ans++;f=1;}}sort(p+1,p+1+n,cmp);/***/
// for(int i=1;i<=n;i++){
// cout<<p[i].name<<' '<<p[i].a<<' '<<p[i].b<<endl;
// }
// cout<<endl;/***/if(f==1){int id;for(int i=1;i<=n;i++){if(p[i].name=="nezha2"){id=i;break;}}int t=0;for(int i=1;i<id;i++){if(t<=p[i].a){ans++;t=p[i].b;}if(t>p[id].a){ans--;break;}}t=p[id].b;for(int i=id+1;i<=n;i++){if(t<=p[i].a){ans++;t=p[i].b;}}}else{int t=0;for(int i=1;i<=n;i++){if(t<=p[i].a){ans++;t=p[i].b;}}}cout<<ans;
}
\[----------------- The \ end-----------------
\]