zoukankan      html  css  js  c++  java
  • (补题 水题 汇总)四川大学第二届SCUACM新生赛

    B-丁姐姐喜欢LCS

    原题链接

    输入

    
    abc
    bca
    wad
    ad
    as
    asd
    wa
    aw
    wa
    wwa  
    
    

    输出

    
    bc
    ad
    as
    a
    
    

    解题思路

    暴力呀!暴力呀!暴力呀!!!(我真是白学了ORZ)

    代码样例

    
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        string a,b;
        while(cin >> a >> b){
            bool judge = false;
            int cnt=0;
            for(int i=0; i < a.length(); i++){
                if(judge){
                    if (a[i] != b[cnt])
                        judge = false;
                }
                if(a[i] == b[cnt]){
                    judge = true;
                    cnt++;
                }
            }
            if(judge)
                for(int i=0;i < cnt; i++)
                    cout << b[i];
            else
                cout << ""NULL!"";
            cout << endl;
        }
        return 0;
    }
    
    

    J-n=abc

    原题链接

    输入

    
    2
    10
    12
    
    

    输出

    
    No solution
    12=2*2*3
    
    

    解题思路

    暴力呀!!!暴力呀!!!暴力呀!!!(我真是白学了ORZ ORZ)

    代码样例

    
    #include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        int t;
        cin >> t;
        while (t--)
        {
            int n;
            cin >> n;
            int a,b,c;
            for(int i = 2; i < n; i++)
                if(n % i == 0)
                {
                    int m = n / i;
                    for(int j = i; j <= m / j + 1; j++)
         
                        if(m % j == 0 && j <= m / j)
                            if(m/j - i < cmp)
                                a = i, b = j, c = m/j, cmp = m/j - i;
                }
            if (judge == n)
                cout << "No solution" << endl;
            else
                cout << n << "=" << a << "*" << b << "*" << c << endl;
        }
        return 0;
    }
    
    

    L-双流机场

    原题链接

    输入

    
    2
    3 3
    010
    010
    3 3
    011
    011
    
    

    输出

    
    Sad
    Happy
    
    

    解题思路

    水题,只需要判断四个角是否能够有出路和入路即可

    代码样例

    
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int t;
        cin >> t;
        while(t--){
            int n,m;
            cin >> n >> m;
            string a,b;
            cin >> a >> b;
            bool judge=false;
            if(a[0] == '0'&&b[m-1] == '0')
                judge = true;
            if(a[0] == '1'&&b[0] == '0')
                judge = true;
            if(a[n-1] == '0'&&b[m-1] == '1')
                judge = true;
            if(a[n-1] == '1'&&b[0] == '1')
                judge = true;
            if(judge)
                cout << "Sad" << endl;
            else
                cout << "Happy" << endl;
        }
        return 0;
    }
    
    

    我知道了,我收拾收拾马上滚ORZ

  • 相关阅读:
    linux系统禁止root用户通过ssh登录及ssh的访问控制
    POJ 3670 , 3671 LIS
    hello world是怎样运行的?
    MFC框架中消失的WinMain()
    [置顶] android LBS的研究与分享(附PPT)
    POJ 3616 DP
    IMP 导入数据报错 OCI-21500 OCI-22275
    误删/tmp导致hadoop无法启停, jsp无法查看的解决方法
    java的文件操作类File
    C#的可空类型与不可空类型
  • 原文地址:https://www.cnblogs.com/cafu-chino/p/11877868.html
Copyright © 2011-2022 走看看