首页 > 代码库 > Codeforces Round #257 (Div. 2)

Codeforces Round #257 (Div. 2)

感言:以后中国高中生的专场还是慎入!!!!


A题目还是比较简单

AC代码:

#include<stdio.h>
#include<algorithm>
using namespace std;
struct p
{
    int number;
    int val;
}num[105];
bool cmp(p x,p y)
{
    if(x.val==y.val)
        return x.number>y.number;
    return x.val>y.val;
}
int main()
{
    int n,m,top,end;
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        int i;
        for(i=0;i<n;i++){
            scanf("%d",&num[i].val);
            num[i].val=(num[i].val+m-1)/m;
            num[i].number=i+1;
        }
        sort(num,num+n,cmp);
        printf("%d\n",num[0].number);
    }
    return 0;
}

B:也简单

不过很容易错,看到好多人这道题挂了

#include<stdio.h>
int a[9];
int m=int(1e9)+7;
int main()
{
    int n;
    scanf("%d %d",&a[1],&a[2]);
    for(int i=3;i<=8;i++)
        a[i]=(a[i-1]-a[i-2]);
    a[0]=a[1]-a[2];<span style="white-space:pre">	</span>//难点
    scanf("%d",&n);
    printf("%d\n",(a[n%6]%m+m)%m);
    return 0;
}

C:找到规律就可以了

#include <iostream>
#include<algorithm>
using namespace std;

int main() {

  int n, m, k;
  cin >> n >> m >> k;

  if (k > m + n - 2) {
    cout << -1 << endl;
    return 0;
  }

  long long x, y, a, b;
  x = min(k + 1, n);
  y = k + 2 - x;
  a = (n / x) * (m / y);
  y = min(k + 1, m);
  x = k + 2 - y;
  b = (n / x) * (m / y);
  cout << max(a, b) << endl;
  return 0;
}