A. Roman and Browser(暴力模拟)
题目链接:codeforces 1100A
题意:
有n个标签,关闭 b + i * k 的标签(i = .....-1,0,1,2.....)b自定,问-1和1的差值最大为多少
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[105];
int main(){
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int ans = 0;
for(int i = 1; i <= k; i++){
int num0 = 0, num1 = 0, t = 0;
for(int j = 1; j <= n; j++){
if(j == i + t * k){
t++;
continue;
}
else{
if(a[j] == 1){
num1++;
}
else{
num0++;
}
}
}
ans = max(ans, abs(num1-num0));
}
cout << ans << endl;
return 0;
}
B Build a Contest
题目链接:codeforces 1100B
题意:
给出n个题的难度,难度不相同的题都出现一次输入1, 否则为0
题解
当所有难度的题出现过一次时(用掉,减一),输出1,否则输出0
就是模拟
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m;
while(cin >> n >> m){
int a[100005], k, sum = 0;
memset(a, 0, sizeof(a));
for(int i = 1; i <= m; i++){
cin >> k;
a[k]++; // 记录难度为k的题目出现的次数
if(a[k] == 1){
sum++; // 出现过一次,总和加一
}
if(sum == n){ // 难度不相同的题目都出现过,输出一
cout << 1;
for(int i = 1; i <= n; i++){
a[i]--; // 难度为i的题目数减一
if(a[i] == 0){
sum--; // 出现的题目数为0,总和减一
}
}
}
else{
cout << 0;
}
}
cout << endl;
}
return 0;
}
C. NN and the Optical Illusion(简单几何)
题目链接:codeforces 1100C
题意:

给出中心圆半径和外圈圆的个数,求外圈圆的半径
题解:
做辅助线,连接中心圆和外圈圆的圆心 sin(π/n)⋅(R+r)=R。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[105];
int main(){
double n, r;
cin >> n >> r;
double PI = atan2(0, -1);
double ans = r*sin(PI/n) /(1-sin(PI/n));
printf("%.6lf\n", ans);
return 0;
}
本文提供了CodeForces 1100A至C三道题目的详细解答,涵盖暴力模拟、简单几何等算法,通过具体代码实现了解题思路。
522

被折叠的 条评论
为什么被折叠?



