云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 蓝桥杯 练习系统 算法提高答案Java

蓝桥杯 练习系统 算法提高答案Java

  • 62 次阅读
  • 3 次下载
  • 2025/12/2 23:28:13

ADV-127 日期计算

import java.util.Scanner;

class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int y = input.nextInt(); int m = input.nextInt(); int d = input.nextInt(); int i, j, k, s1 = 0, s2 = 0, x = 0, s, z = 0; for (i = 1; i < 2011; i++) { s1 = s1 + 365; if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0)) { s1++; } } s1 = s1 + 315; for (j = 1; j < y; j++) { s2 = s2 + 365; if ((j % 4 == 0 && j % 100 != 0) || (j % 400 == 0)) { s2++; } } for (i = 1; i < m; i++) { if(i==1) s2=s2+31; if(i==2) {s2=s2+28; if((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {s2++;} } if(i==3) s2=s2+31; if(i==4) s2=s2+30; if(i==5) s2=s2+31; if(i==6) s2=s2+30; if(i==7) s2=s2+31;

if(i==8) s2=s2+31; if(i==9) s2=s2+30; if(i==10) s2=s2+31; if(i==11) s2=s2+30;

}

s2 = s2 + d;

s = s2 - s1; if (s < 0) { s = 0 - s; z = 1; }

if (z == 0) { x = (s % 7) + 5; if (s % 7 > 2) { x = x % 7; }

} else if (z == 1) { x = 5 - (s % 7); if (s % 7 == 5) x = 7; if (s % 7 == 6) x = 6; }

System.out.println(x);

}

}

ADV-123

import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); double[][] dp=new double[110][11000];

概率计算

}

}

int n=sc.nextInt(); int a=sc.nextInt(); int b=sc.nextInt(); int x=sc.nextInt();

double p=1.0/(b-a+1); for(int i=1;i<=n;i++){ for(int j=a*i;j<=b*i&&j<=x;j++){ if(i==1) { dp[i][j]=p; }else{ double pp=0; for(int z=a;z<=b;z++){ if(j>=z) pp+=dp[i-1][j-z]*p; } dp[i][j]=pp; } } }

System.err.printf(\

ADV-120 6-17复数四则运算

import java.util.Scanner;

public class Main{ /** * @author linfan */ public static void main(String[] args) { Scanner sc=new Scanner(System.in); String[] ss=sc.nextLine().split(\ int a=Integer.parseInt(ss[0]); int b=Integer.parseInt(ss[1]); int c=Integer.parseInt(ss[3]); int d=Integer.parseInt(ss[4]); char ch=ss[2].charAt(0); int p,q; String s=\ switch(ch){ case '+': p=a+c;q=b+d; if(p!=0)s+=p;

}

}

if(q>0) s+=\ if(q<0) s+=q+\ break; case '-': p=a-c;q=b-d; if(p!=0)s+=p; if(q>0) s+=\ if(q<0) s+=q+\ break; case '*': p=a*c-b*d;q=b*c+a*d; if(p!=0)s+=p; if(q>0) s+=\ if(q<0) s+=q+\ break; case '/': int m=c*c+d*d; if(m==0){ s=\ } double p1=(a*c+b*d)*1.0/m; double q1=(b*c-a*d)*1.0/m; if(p1!=0){ if((a*c+b*d)%m==0)s+=(int)p1; else s+=p1; } if(q1>0){ if((b*c-a*d)%m==0)s+=\ else s+=\ } if(q1<0){ if((b*c-a*d)%m==0)s+=(int)q1+\ else s+=q1+\ } break; default:break; }

System.out.println(s);

ADV-112 c++_ch02_01

public class Main { public static void main(String[] args) { System.out.println((int)'A'); System.out.println((int)'E');

搜索更多关于: 蓝桥杯 练习系统 算法提高答案Java 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

ADV-127 日期计算 import java.util.Scanner; class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int y = input.nextInt(); int m = input.nextInt(); int d = input.nextInt(); int i, j, k, s1 = 0, s2 = 0, x = 0, s, z = 0; for (i = 1; i < 2011; i++) { s1 = s1 + 365; if ((i % 4 == 0 && i % 100 !

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com