招行卡中心提前批笔试做到自闭
第一题第二题我觉得自己思考方向是对的,样例也过了,但通过率怎么搞都是0,到底是哪里出错了。。。我真的好崩溃。。。真的很喜欢招行,诶
贴一下题目和代码,希望有大神可以不吝赐教
第一题:
![](https://uploadfiles.nowcoder.com/message_images/20190721/655926511_1563724223405_discuss_1563724222904.jpeg)
![](https://uploadfiles.nowcoder.com/message_images/20190721/655926511_1563724240174_discuss_1563724239635.jpeg)
![](https://uploadfiles.nowcoder.com/message_images/20190722/655926511_1563725544124_discuss_1563725543698.jpeg)
#笔试题目##招商银行信用卡中心#
贴一下题目和代码,希望有大神可以不吝赐教
第一题:
![](https://uploadfiles.nowcoder.com/message_images/20190721/655926511_1563724223405_discuss_1563724222904.jpeg)
![](https://uploadfiles.nowcoder.com/message_images/20190721/655926511_1563724240174_discuss_1563724239635.jpeg)
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt())
{
int n = sc.nextInt();
double ans = 0;
double x;
double []a=new double[n];
for(int i = 0; i < n; i ){
x = sc.nextDouble();
a[i] = x;
}
Arrays.sort(a);
if(n==1) {
NumberFormat nf =NumberFormat.getNumberInstance();
nf.setMinimumFractionDigits(4);
System.out.println(nf.format(a[0]));
}
else
{
ans =a[0]/Math.pow(2, n-1);
ans =a[1]/Math.pow(2, n-1);
for(int i=2;i<n;i )
{
ans =a[i]*Math.pow(2, i-n);
}
NumberFormat nf =NumberFormat.getNumberInstance();
nf.setMinimumFractionDigits(4);
System.out.println(nf.format(ans));
}
}
}
}
第二题:
![](https://uploadfiles.nowcoder.com/message_images/20190722/655926511_1563725544124_discuss_1563725543698.jpeg)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m=sc.nextInt();
int[][]a=new int[n][m];
int t1=0;
int t2=0;
int row1=0;
int row2=0;
int col1=0;
int col2=0;
for(int i = 0; i < n; i ){
for(int j = 0; j < m; j ){
a[i][j] = sc.nextInt();
if(a[i][j]>t1) {
t1=a[i][j];
row1=i;
col1=j;
}
}
}
for(int i = 0; i < n; i ){
for(int j = 0; j < m; j ){
if(!(i==row1&&j==col1)){
if(a[i][j]>t2) {
t2=a[i][j];
row2=i;
col2=j;
}
}
}
}
if(row1!=row2&&col1!=col2) {
System.out.println(t1*t2);
}
else {
int t3=0;
for(int i = 0; i < n; i ){
for(int j = 0; (j < m); j ){
if((i!=row1)&&(j!=col1)) {
if(a[i][j]>t3) {
t3=a[i][j];
}
}
}
}
int t4=0;
for(int i = 0; i < n; i ){
for(int j = 0; j < m; j ){
if((i!=row2)&&(j!=col2)) {
if(a[i][j]>t4) {
t4=a[i][j];
}
}
}
}
System.out.println(Math.max(t3*t1, t2*t4));
}
}
}