zoukankan      html  css  js  c++  java
  • [比赛]2015/12/25BNU新生赛

      网络同步做了半个小时,然后就拉肚子了……嗯……

    A:不解释……5min 1A

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 inline int max(int a, int b) {
    21     return a > b ? a : b;
    22 }
    23 
    24 int main() {
    25     int T;
    26     int a, b;
    27     scanf("%d", &T);
    28     while(T--) {
    29         scanf("%d%d", &a, &b);
    30         int xx = max(a, b);
    31         if(xx * 5 < 1000) {
    32             printf("1000
    ");
    33         }
    34         else if(xx * 5 >= 60000) {
    35             printf("60000
    ");
    36         }
    37         else {
    38             printf("%d
    ", xx * 5);
    39         }
    40     }
    41 }
    A

    B:看样例,看看代码里面奇怪的地方,不解释……1min 1A

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 inline int max(int a, int b) {
    21     return a > b ? a : b;
    22 }
    23 
    24 int main() {
    25     int T;
    26     scanf("%d", &T);
    27     while(T--) {
    28         int n;
    29         scanf("%d", &n);
    30         printf("%d
    ", -n);
    31     }
    32     return 0;
    33 }
    B

    C:读错题了好几次,贪心起始时间,然后从头开始走,看当前时间是否已经布置了作业。如果布置了那么就不加间隔时间,没布置要加上间隔时间…… 20min 3A

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 using namespace std;
    21 
    22 typedef struct QAQ {
    23     int a;
    24     int b;
    25 }Q;
    26 
    27 bool cmp(Q x, Q y) {
    28     if(x.a == y.a) {
    29         return x.b < y.b;
    30     }
    31     return x.a < y.a;
    32 }
    33 
    34 const int maxn = 1111;
    35 int n, t;
    36 Q q[maxn];
    37 
    38 int main() {
    39    // freopen("in", "r", stdin);
    40     int Qrz;
    41     scanf("%d", &Qrz);
    42     while(Qrz--) {
    43         scanf("%d", &n);
    44         for(int i = 0; i < n; i++) {
    45             scanf("%d %d", &q[i].a, &q[i].b);
    46         }
    47         sort(q, q+n, cmp);
    48         t = 0;
    49         int cur = 0;
    50         int cnt = 0;
    51         if(q[0].a > 0) {
    52             t += q[0].a + q[0].b;
    53             cnt++;
    54             cur = q[0].a;
    55         }
    56         for(cnt; cnt < n; cnt++) {
    57             if(t >= q[cnt].a) {
    58                 t += q[cnt].b;
    59                 cur += q[cnt].a;
    60             }
    61             else {
    62                 t += (q[cnt].a - t) + q[cnt].b;
    63             }
    64         }
    65         printf("%d
    ", t);
    66     }
    67     return 0;
    68 }
    C

    D:以前做过类似的题(doge那个…),KMP可以搞,O(n)也可以搞,随意了…… 10min 1A

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 using namespace std;
    21 
    22 const int maxn = 66666;
    23 int na;
    24 char a[maxn];
    25 char* b = "QAQ";
    26 int nb = strlen(b);
    27 int pre[maxn];
    28 
    29 void getpre(char *b, int *pre) {
    30     int j, k;
    31     pre[0] = -1;
    32     j = 0;
    33     k = -1;
    34     while(j < nb) {
    35         if(k == -1 || b[j] == b[k]) {
    36             j++;
    37             k++;
    38             pre[j] = k;
    39         }
    40         else {
    41             k = pre[k];
    42         }
    43     }
    44 }
    45 
    46 int kmp() {
    47     int ans = 0;
    48     int i = 0;
    49     int j = 0;
    50     while(i < na) {
    51         if(j == -1 || a[i] == b[j]) {
    52             i++;
    53             j++;
    54         }
    55         else {
    56             j = pre[j];
    57         }
    58         if(j == nb) {
    59             ans++;
    60         }
    61     }
    62     return ans;
    63 }
    64 
    65 int main() {
    66     getpre(b, pre);
    67     int T;
    68     scanf("%d", &T);
    69     while(T--) {
    70         memset(a, 0, sizeof(a));
    71         scanf("%s", a);
    72         na = strlen(a);
    73         printf("%d
    ", kmp());
    74 
    75     }
    76     return 0;
    77 }
    D

    H:四边形对顶角互补,因此任意四边形均可密铺,Q神永远很happy…… ∞min 1A

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <iomanip>
     4 #include <cstring>
     5 #include <climits>
     6 #include <complex>
     7 #include <fstream>
     8 #include <cassert>
     9 #include <cstdio>
    10 #include <bitset>
    11 #include <vector>
    12 #include <deque>
    13 #include <queue>
    14 #include <stack>
    15 #include <ctime>
    16 #include <set>
    17 #include <map>
    18 #include <cmath>
    19 
    20 using namespace std;
    21 
    22 typedef long long LL;
    23 
    24 int main() {
    25     int T;
    26     LL x1,x2,x3,x4,y1,y2,y3,y4;
    27     scanf("%d",&T);
    28     while(T--) {
    29         scanf("%lld %lld %lld %lld %lld %lld %lld %lld",&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
    30         printf("BQG is happy!
    ");
    31     }
    32     return 0;
    33 }
    H

    下面是理论AK阶段……

    E:处理字串,先找一遍数字和匹配一遍"(n"以及"(log"字样,(可以胡来也可以ac自动机),接着把数字处理出来就可以AC啦……

    F:嗯…是个数学题,找找规律胡搞一下肯定能过……

    G:一定是个贪心+二分……胡搞一定能过……

  • 相关阅读:
    python字符串操作
    python学习【一】基础入门
    markdown 编辑器
    jenkins学习笔记-安装
    算法
    python 修改文件内容
    python基础,python第四课
    python基础,python第三课
    python基础,python第二课
    python基础,python第一课
  • 原文地址:https://www.cnblogs.com/kirai/p/5077244.html
Copyright © 2011-2022 走看看