zoukankan      html  css  js  c++  java
  • 414某OJ竞赛题

    D题【不知道哪里错了,一直WA】

    Draw Something Cheat

     

    Time Limit: 2 Seconds      Memory Limit: 65536 KB 

     

    Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You need to pick a word and draw a picture for this word. Then your friend will be asked what the word is, given the picture you have drawn. The following figure illustrates a typical scenario in guessing the word. 

     

    As you see, when guessing a word you will be given the picture and 12 letters. You must pick some of these letters to form a word that matches the picture. Each letter can only be used once. It is a lot of fun if your friend is a talented painter, but unfortunately some drawings from your friend are totally incomprehensible. After several times of becoming mad by the drawings, you find a way to cheat in the game. 

    In this game, letters not included in the correct answer are randomly generated. If you cannot find the correct answer when guessing, you can write down all the letters and restart the game. Then you would find some of these letters are changed. Of course these changed letters will never appear in the answer. By eliminating these letters you are a step closer to the answer. 

    So In this problem, you need to write a program to automate the cheating process. Given N strings of letters to the same picture, you need to eliminate as many letters as possible, and output the remaining letters. 

    Input

    There are multiple test cases. The first line of the input is an integer T ≈ 1000 indicating the number of test cases. 

    Each test case begins with a positive integer N ≤ 20 indicating the number of times you have entered the game. Then N lines follow. Each line is a string of exactly 12 uppercase letters, indicating the candidate letters in one guess. It is guaranteed that the answer has at least 1 letter and has no more than 12 letters. 

    Output

    For each test case, output the remaining letters in alphabet order after the process described above. One line for each test case. 

    Sample Input

    2

    2

    ABCDEFGHIJKL

    ABCDEFGHIJKL

    2

    SAWBCVUXDTPN

    ZQTLFJYRCGAK

    Sample Output

    ABCDEFGHIJKL

    ACT

    #include <stdio.h>
    #include <string.h>
    int main()
    {
        int T,n,i,j,alph[26];
        char str[15];
        scanf("%d",&T);
        while (T--)
        {
            memset(alph,0,sizeof(alph));
            scanf("%d",&n);
            for (i=0;i<n;i++)
            {
                scanf("%s",str);
                for (j=0;j<12;j++)
                    alph[str[j]-'A']++;
            }
            for (i=0;i<26;i++)
            {
                if (alph[i]==n)
                    printf("%c",'A'+i);
            }
            printf("\n");
        }
        return 0;
    }

    J题

    Modular Inverse

     

    Time Limit: 2 Seconds      Memory Limit: 65536 KB 

     

    The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m). 

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 2000 indicating the number of test cases. 

    Each test case contains two integers 0 < a ≤ 1000 and 0 < m ≤ 1000. 

    Output

    For each test case, output the smallest positive x. If such x doesn't exist, output "Not Exist". 

    Sample Input

    3

    3 11

    4 12

    5 13

    Sample Output

    4

    Not Exist

    8

    #include <stdio.h>
    int T,x,a,m;
    int main()
    {
        int i,t;
        scanf("%d",&T);
        while(T--)
        {
            x=-1;
            scanf("%d%d",&a,&m);
            for(i=0;i<1005;i++)//不知道这里要写多少,就写了个1000+
            {
                t=m*i+1;
                if(t%a==0)
                {
                    x=t/a;
                    break;
                }
                    
            }
            if(x>0)
                printf("%d\n",x);
            else
                printf("Not Exist\n");
        }
        return 0;
    }


    K题

    Yet Another Story of Rock-paper-scissors

     

    Time Limit: 2 Seconds      Memory Limit: 65536 KB 

     

    Akihisa and Hideyoshi were lovers. They were sentenced to death by the FFF Inquisition. Ryou, the leader of the FFF Inquisition, promised that the winner of Rock-paper-scissors would be immune from the punishment. Being lovers, Akihisa and Hideyoshi decided to die together with their fists clenched, which indicated rocks in the game. However, at the last moment, Akihisa chose paper and Hideyoshi chose scissors. As a result, Akihisa was punished by the FFF Inquisition and Hideyoshi survived alone. 

    When a boy named b and a girl named g are being punished by the FFF Inquisition, they will play Rock-paper-scissors and the winner will survive. If there is a tie, then neither of they will survive. At first, they promise to choose the same gesture x. But actually, the boy wants to win and the girl wants to lose. Of course, neither of them knows that the other one may change his/her gesture. At last, who will survive? 

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases. 

    Each test case contains three strings -- b g x. All strings consist of letters and their lengths never exceed 20. The gesture x is always one of "rock", "paper" and "scissors". 

    Output

    If there is a tie, output "Nobody will survive". Otherwise, output "y will survive" where y is the name of the winner. 

    Sample Input

    1

    Akihisa Hideyoshi rock

    Sample Output

    Hideyoshi will survive

    #include <stdio.h>
    char b[25],g[25],x[25];
    int T;
    int main()
    {
        scanf("%d",&T);
        while(T--)
        {
            scanf("%s%s%s",b,g,x);
            printf("%s will survive\n",g);
        }
        return 0;
    }
    字节跳动内推

    找我内推: 字节跳动各种岗位
    作者: ZH奶酪(张贺)
    邮箱: cheesezh@qq.com
    出处: http://www.cnblogs.com/CheeseZH/
    * 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    BlockingQueue 原理 分析
    java引用 强引用,软引用,弱引用
    actomic cas无锁操作。
    MongoDB库设计原则及实践
    spring事物传播机制 事物隔离级别
    Hive UDAF介绍与开发
    [技术学习]js接口继承
    [技术学习]js继承
    [技术学习]正则表达式分析
    [技术学习]js正则表达式汇总
  • 原文地址:https://www.cnblogs.com/CheeseZH/p/2447424.html
Copyright © 2011-2022 走看看