目录
A Air Conditioner
B Distance
C Repsept
D Alter Altar
E Logs
F Range Set Query
A | B | C | D | E | F |
---|---|---|---|---|---|
√ | √ | ● | ○ | ● | ● |
( √:做出; ●:尝试未做出; ○:已补题 )
题目地址:https://atcoder.jp/contests/abc174
T1:
题意:输入一个整数如果大于等于30要开空调,输出"Yes";否则输出"No"
思路:同上
代码:
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
int x;
cin>>x;
if(x>=30) puts("Yes");
else puts("No");
return 0;
}
T2:
题意:输入n个坐标,判断xx+yy是否小于等于d
思路:如果小于等于d*d,ans++
代码:
#include <iostream>
using namespace std;
int ans, n;
long long d, x, y;
int main(){
cin>>n>>d;
while(n--)
{
cin>>x>>y;
if(x*x+y*y<=d*d)
ans++;
}
cout<<ans;
}
T3:
题意:
思路:
代码:
T4:
题意:把所有的白石放在红石后面
思路:用类似前缀和的方法来做,用b(n,1)来表示到第n个数有多少个红色的,b(n,0)来表示到第n个数有多少个白色的,最后要RRR…RWWW…W,结果输出变到上面这个字符串需要的步数(b(r, 0))
代码:
#include <iostream>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,b[N][2];
char str[N];
int main()
{
cin>>n>>str+1;
for(int i=1; i<=n; i++)
{
if(str[i]=='R') b[i][1]=b[i-1][1]+1,b[i][0]=b[i-1][0];
else b[i][1]=b[i-1][1],b[i][0]=b[i-1][0]+1;
}
int r=b[n][1],w=b[n][0];
int ans=min(b[r][0],min(w,r));
cout<<ans;
return 0;
}