• Facebook Hacker Cup 2018 Qualification Round


    25: Tourist

    暴力

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long LL;
     4 string str[111];
     5 vector<string> v;
     6 map<string, int> mp;
     7 bool cmp(string a, string b) {
     8     return mp[a] < mp[b];
     9 }
    10 
    11 int main() {
    12     freopen("tourist.txt", "r", stdin);
    13     freopen("tourist_out.txt", "w", stdout);
    14     int T;
    15     scanf("%d", &T);
    16     for(int kase = 1; kase <= T; ++kase) {
    17         LL K, N, V;
    18         scanf("%lld %lld %lld", &N, &K, &V);
    19         v.clear();
    20         mp.clear();
    21         for(int i = 0; i < N; ++i) cin >> str[i], mp[str[i]] = i;
    22         int st = (K * (V - 1) - 1) % N;
    23         printf("Case #%d:", kase);
    24         for(int i = 1; i <= K; ++i) st = (st + 1) % N, v.push_back(str[st]);
    25         sort(v.begin(), v.end(), cmp);
    26         for(int i = 0; i < v.size(); ++i) printf(" %s", v[i].c_str());
    27         puts("");
    28     }
    29     return 0;
    30 }
    Aguin

    30: Interception

    判奇偶

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main() {
     5     freopen("interception.txt", "r", stdin);
     6     freopen("interception_out.txt", "w", stdout);
     7     int T;
     8     scanf("%d", &T);
     9     for(int kase = 1; kase <= T; ++kase) {
    10         int N, x;
    11         scanf("%d", &N);
    12         for(int i = N; i >= 0; --i) scanf("%d", &x);
    13         if(N & 1) printf("Case #%d: 1
    0
    ", kase);
    14         else printf("Case #%d: 0
    ", kase);
    15     }
    16     return 0;
    17 }
    Aguin

    45: Ethan Searches for a String

    找一个和前缀一样的

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 char A[2222];
     4 
     5 int main() {
     6     freopen("ethan_searches_for_a_string.txt", "r", stdin);
     7     freopen("ethan_searches_for_a_string_out.txt", "w", stdout);
     8     int T;
     9     scanf("%d", &T);
    10     for(int kase = 1; kase <= T; ++kase) {
    11         scanf("%s", A + 1);
    12         printf("Case #%d: ", kase);
    13         int la = strlen(A + 1), flag = 0;
    14         for(int i = 2; i <= la; ++i) {
    15             if(A[i] != A[1]) continue;
    16             int ok = 0;
    17             for(int j = i; j <= la; ++j)
    18                 if(A[j] != A[j-i+1]) {ok = 1; break;}
    19             if(ok) {
    20                 for(int j = 1; j < i; ++j) putchar(A[j]);
    21                 puts(A + 1);
    22                 flag = 1;
    23                 break;
    24             }
    25         }
    26         if(!flag) puts("Impossible");
    27     }
    28     return 0;
    29 }
    Aguin
  • 相关阅读:
    split 使用
    python中接受上一条命令执行的结果----subprocess.check_output()
    k8s开启cadvisor http 服务
    Spring Cloud之配置中心搭建
    如何高效地学习开源项目
    Spring Boot之默认连接池配置策略
    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: ..... this is incompatible with sql_mode=only_full_group_by
    com.netflix.zuul.exception.ZuulException: Forwarding error
    设置环境变量相关命令
    java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
  • 原文地址:https://www.cnblogs.com/Aguin/p/9292902.html
Copyright © 2020-2023  润新知