Park Lighting CodeForces - 1358A
思路:水题不解释。
代码如下:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
ll ans=(n/2)*m+((n%2==0)?0:(m/2+((m%2==0)?0:1)));
cout<<ans<<endl;
}
return 0;
}
Maria Breaks the Self-isolation CodeForces - 1358B
思路:排序之后,遍历就可以了。注意细节
代码如下:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxx=1e5+100;
int a[maxx];
int n;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+1+n);
int ans=1;
int cnt=1;
for(int i=1;i<=n;i++)
{
if(cnt>=a[i]) ans=cnt+1;
cnt++;
}
cout<<ans<<endl;
}
return 0;
}
努力加油a啊,(o)/~