继续干codeforces。
https://codeforces.com/[这里是图片001]https://codeforces.com/
目录
7A - Kalevitch and Chess

题目大意:给出8*8的国际象棋棋盘,每次可以把一行或者一列变成W,问全部变成W需要操作多少次。
题目思路:统计最少需要的操作的行或者列的个数,按照贪心的思想,如果某行全部为B,肯定会操作这一行,否则就可能会操作列。
AC代码:

#include<bits/stdc++.h>
#define AC return 0;
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int ans,a=0,b=9;
for(int i=0;i<8;i++){
string s; cin>>s;
int cnt=0;
for(int j=0;j<8;j++) if(s[j]=='B') cnt++;
if(cnt==8) a++;
b=min(b,cnt);
}
if(a==8) ans=8;
else ans=a+b;
cout<<ans;
AC
}
//ACplease!!!
/* printf("
");
printf("
");
printf(" * * * * * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * * * * * * * * * * * * * * * * * * * * *
");
*/
9A - Die Roll

题目大意:三个人置筛子,现在给出前两个人的点数,只要第三个人的点数大于等于前两个人的,第3个则胜出,求第三个人胜出的概率。如果是0,输出0/1;如果是1,输出1/1。否则 化简后按分数模式输出。
题目思路:总归就6种可能,条件判断。
AC代码:

#include<bits/stdc++.h>
#define AC return 0;
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int y,w; cin>>y>>w;
int mx=max(y,w);
if(mx==1) cout<<"1/1";
if(mx==2) cout<<"5/6";
if(mx==3) cout<<"2/3";
if(mx==4) cout<<"1/2";
if(mx==5) cout<<"1/3";
if(mx==6) cout<<"1/6";
AC
}
//ACplease!!!
/* printf("
");
printf("
");
printf(" * * * * * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * * * * * * * * * * * * * * * * * * * * *
");
*/
11A - Increasing Sequence

题目大意:给你一个数组和一个正整数d。在每次操作中,你可以选择数组中的一个元素,将d添加到其中(可操作多次)。使数组的元素逐个增加,最少操作多少次?
题目思路:很简单,按部就班,没什么算法。
AC代码:

#include<bits/stdc++.h>
#define geta(n,m) for(int i=n;i<m;i++){cin>>a[i];}
#define AC return 0;
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n,d,cnt=0; cin>>n>>d;
vector<int>a(n+5);
geta(0,n);
for(int i=0;i<n-1;i++)
if(a[i]>=a[i+1]){
cnt+=(a[i]-a[i+1])/d+1;
a[i+1]+=((a[i]-a[i+1])/d+1)*d;
}
cout<<cnt;
AC
}
//ACplease!!!
/* printf("
");
printf("
");
printf(" * * * * * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * *
");
printf(" * * * * * * * * * * * * * * * * * * * * * * * *
");
*/
刷题计划还在继续……


995

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



