• best matched pair


    今天的模拟赛,被虐的不行。。。。英文太差,弄不懂题意,弄懂题意了还不会。。。

    感觉快要受不了了。。。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    
    int judge(int t){
        int intge[15];
        int cou=0;
        while(t>=10){
            int p=t%10;
            t/=10;
            intge[cou++]=p;
        }
        intge[cou++]=t;
        for(int i=0;i<cou-1;i++){
            if(intge[i]<=intge[i+1]||(intge[i]-intge[i+1])!=1){
                return 0;
            }
        }
    
        return 1;
    }
    
    int main()
    {
        int n;
        int a[1005];
        int b=0;
        while(scanf("%d",&n)!=EOF){
            b=0;
            for(int i=0;i<n;i++){
                scanf("%d",&a[i]);
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    if(j!=i){
                        int t=a[j]*a[i];
                        if(judge(t)&&b<t){
                            b=t;
                        }
                    }
                }
            }
            if(b==0){
                printf("-1
    ");
            }else{
                printf("%d
    ",b);
            }
        }
        return 0;
    }
  • 相关阅读:
    计算器
    安卓第四周作业
    安卓第三次作业
    补10.21
    补:10.21
    增删改查
    android-數據庫
    安卓 -登陆界面
    android 第Ⅱ次作业
    第一个java代码
  • 原文地址:https://www.cnblogs.com/TWS-YIFEI/p/5929601.html
Copyright © 2020-2023  润新知