[问题描述]

A国估计被测的民众的感染率大概是1%，呈均匀分布。请问k取多少能最节省试剂盒?

[答案提交]

package com.Test.Demo.第十一届蓝桥杯; public class Main_C { public static void main(
String[] args) { int min=999990; int ans=-1; for(int i=1;i<=100;i++){ //i个人一块测
int temp; if(100%i!=0){ temp = 100/i+i+1; }else{ temp = 100/i+i; } if(min>temp){
min=temp; ans=i; } } System.out.println(ans); } }

[问题描述]

[输入格式]一个数字序列。

[输出格式]

[样例输入]123242526

[样例输出]LCXYZ

[评测用例规模与約定]

import java.util.Scanner; public class Main { public static void main(String[]
args) { Scanner input = new Scanner(System.in); String s = input.next(); int len
= s.length(); char[] c = s.toCharArray(); int i; for(i = 0; i < len-1; i++) {
int a = c[i]-'0'; int b = c[i+1]-'0'; int ans = a*10+b; if(ans<27) { char ch = (
char) (ans+64); System.out.print(ch); i++; }else { char ch = (char) (a+64);
System.out.print(ch); } } if(i < len){ char ch = (char) (c[i]-'0'+64); System.
out.print(ch); } } }

[问题描述]

1(10)

2(0)

3(20)

4(30)

[输入格式]

import java.util.Scanner; public class Main { public static void main(String[]
args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k =
input.nextInt(); int a[] = new int[100100]; int b[] = new int[100100]; int vis[
] = new int[100010]; for(int i = 1; i <= n; i++) { a[i] = input.nextInt(); b[i]
= input.nextInt(); vis[i] = a[i]; } int cnt = 0; int ans = 0; for(int i = 1; i
<= n; i++) { if(vis[i]==k) { cnt++; ans = b[i]; } } if(cnt==2) System.out.print(
0); else if(cnt==1) { ans = Math.abs(ans-b[k]); System.out.print(ans-1); }else
System.out.print(-1); } }

GitHub

Gitee