美文网首页
2020-08-11宇宙总统

2020-08-11宇宙总统

作者: JalorOo | 来源:发表于2020-08-11 21:55 被阅读0次

https://www.luogu.com.cn/problem/P1781

#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstring>
using namespace std;
#define MAXN 5010//高精的位数

long long qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k&1) res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}

int read(){
    int x = 0,f = 1;
    char c = getchar();
    while (c<'0'||c>'9') {
        if (c=='-') {
            f = -1;
        }
        c = getchar();
    }
    while (c>='0'&&c<='9') {
        x = x*10+c-'0';
        c = getchar();
    }
    return x*f;
}

//int peace(int floor){
//    if (floor == 2) {
//        return 2;
//    }
//    if(floor == 1){
//        return 1;
//    }
//    if (f[floor]!=0) {
//        return f[floor];
//    }
//    f[floor] = peace(floor-1)+peace(floor-2);
//    return f[floor];
//}


int main()
{
    int n = read();
    string num;
    int pos = -1;
    string ans;
    for (int i = 1; i<=n; i++) {
        cin>>num;
        if (num.length()>ans.length()||i==1) {
            pos = i;
            ans = num;
        }else if(num.length() == ans.length()){
            if(strcmp(num.c_str(), ans.c_str())>0){
                ans = num;
                pos = i;
            }
        }
    }
    cout<<pos<<endl<<ans;
    return 0;
}
/*
 5
 98765
 12365
 87954
 1022356
 985678
 
 2
 12039476
 48607056
 
============
4
 1022356
 
 2
 48607056
*/

相关文章

网友评论

      本文标题:2020-08-11宇宙总统

      本文链接:https://www.haomeiwen.com/subject/ttludktx.html