题目链接:https://www.zhixincode.com/problem/day2-2
数据范围太大,需要用unsigned long long,不知道为什么字符串的方法过不了..
AC代码:
代码语言:javascript复制#include <bits/stdc .h>
#define ll unsigned long long
#define maxn 6005
using namespace std;
ll pre[maxn];
int T,n;
ll fun(ll a, ll b){
ll xx = b, cnt = 1;
while(xx){
xx /= 10;
cnt *= 10;
}
a *= cnt;
return a b;
}
int main()
{
int Case = 1;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=0;i<n;i ){
scanf("%llu",&pre[i]);
}
ll ans = 0;
for(int i=0;i<n;i ){
for(int j=i 1;j<n;j ){
ans = max(ans, fun(pre[i], pre[j]));
}
}
printf("Case #%d: %llun",Case , ans);
}
return 0;
}