//平均年龄
package enterprise;
import java.util.Scanner;
publicclass Main
{
publicstaticintaverageAge(int w, int y, double x, int n)
{
double aver_age = y;
for(int i = 1; i <= n; i++)
{
aver_age = (x * 21) +(aver_age + 1)*(1 - x); //在过程中使用double类型,最后再转换为int类型
}
return (int)Math.ceil(aver_age);
}
publicstaticvoidmain(String[] args) {
Scanner sc = new Scanner(System.in);//学习Scanner类的用法while(sc.hasNext())//当输入有值时,hasNext()一个单词一个单词的取值
{
int W = sc.nextInt();//输入intint Y = sc.nextInt();
double x = sc.nextDouble();//输入doubleint N = sc.nextInt();
System.out.println(averageAge(W,Y,x,N));
}
}
}
//钓鱼比赛
package enterprise;
import java.util.Scanner;
publicclass Fish {
publicstaticvoidfish(double[][] p, int n, int m, int x, int y, int t){
double cc = 1 - Math.pow(1 - p[x][y], t);
double ssp = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
ssp += (p[i][j]/(n*m));
}
double ss = 1 - Math.pow(1 - ssp, t);;
if(cc > ss)
{
System.out.println("cc");
System.out.println(String.format("%.2f", cc));
}
elseif(cc < ss)
{
System.out.println("ss");
System.out.println(String.format("%.2f", ss));
}
else
{
System.out.println("equal");
System.out.println(String.format("%.2f", cc));
}
}
publicstaticvoidmain(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int m = sc.nextInt();
int x = sc.nextInt() - 1;
int y = sc.nextInt() - 1;
int t = sc.nextInt();
sc.nextLine(); //把第一行取完,完成换行的目的double[][] p = newdouble[n][m];
for(int i = 0; i < n; i++)
{
String[] s = sc.nextLine().split(" "); //从输入的第二行开始将每一行读到的数字按照空格分开存放在字符串数组s中,这个数组s的大小就是mfor(int j = 0; j < m; j++)
{
p[i][j] = Double.parseDouble(s[j]);//然后再把每一个字符串强转放到二维数组里面
}
}
fish(p, n, m, x, y, t);
}
}
}
//最高分是多少
package enterprise;
import java.util.Scanner;
publicclass MaxScore {
publicstaticvoidmaxScore(char c, int left, int right, int[] score) {
if(c == 'Q'){ //查询最大值if(left > right) {int temp = right; right = left; left = temp;}
int max = score[left - 1];
for(int i = left; i < right; i++)
{
if(score[i] > max)
max = score[i];
}
System.out.println(max);
}
else//更新
score[left-1] = right;
}
publicstaticvoidmain(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
sc.nextLine();
String[] s = sc.nextLine().split(" ");
int[] score = newint[n];
for(int i = 0; i < n; i++) {
score[i] = Integer.parseInt(s[i]);
}
char c = ' ';
int left = 0;
int right = 0;
for(int i = 0; i < m; i++) {
String[] s1 = sc.nextLine().split(" ");
c = s1[0].charAt(0);
left = Integer.parseInt(s1[1]);
right = Integer.parseInt(s1[2]);
maxScore(c, left, right, score);
}
}
}
}