Educational Codeforces Round 88 (Rated for Div. 2)(A&&B)

Berland Poker CodeForces - 1359A
代码如下:

#include
#define ll long long
using namespace std;

int n,m,k;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&n,&m,&k);
		if(m<=n/k) cout<<m<<endl;
		else
		{
			int num1=n/k;
			m-=num1;
			if(m%(k-1)==0) cout<<num1-m/(k-1)<<endl;
			else cout<<num1-m/(k-1)-1<<endl;
		}
	}
	return 0;
}

New Theatre Square CodeForces - 1359B
代码如下:

#include
#define ll long long
using namespace std;

const int maxx=1e2+100;
char s[maxx][maxx*10];
int n,m,x,y;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d%d",&n,&m,&x,&y);
		for(int i=1;i<=n;i++) scanf("%s",s[i]);
		int flag=1;
		if(x*2>y) flag=0;
		int ans=0;
		if(flag)
		{
			for(int i=1;i<=n;i++)
			for(int j=0;j<m;j++) if(s[i][j]=='.') ans+=x;
		}
		else
		{
			for(int i=1;i<=n;i++)
			{
				for(int j=0;j<m;j++)
				{
					if(s[i][j]=='.')
					{
						if(j+1<m&&s[i][j+1]=='.') ans+=y,j++;
						else ans+=x;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

努力加油a啊,(o)/~

你可能感兴趣的:(Educational Codeforces Round 88 (Rated for Div. 2)(A&&B))