九度oj--1002和1045
来源:互联网 发布:济宁知豆电动汽车电话 编辑:程序博客网 时间:2024/05/20 19:15
题目1002:Grading
题目描述:
Grading hundreds of thousands of Graduate Entrance Exams is a hard work. It is even harder to design a process to make the results as fair as possible. One way is to assign each exam problem to 3 independent experts. If they do not agree to each other, a judge is invited to make the final decision. Now you are asked to write a program to help this process.
For each problem, there is a full-mark P and a tolerance T(
import java.util.*;public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int p,t,g1,g2,g3,gj,max; double grade; while(cin.hasNext()){ p = cin.nextInt(); t = cin.nextInt(); g1 = cin.nextInt(); g2 = cin.nextInt(); g3 = cin.nextInt(); gj = cin.nextInt(); grade = 0.0; if(Math.abs(g1 - g2) <= t) grade = (double)(g1 + g2)/2; else if(Math.abs(g1-g3) <= t && Math.abs(g2-g3) <= t){ max = g1; if(g2 > max) max = g2; if(g3 > max) max = g3; grade = max; } else if(Math.abs(g1 - g3) <= t) grade = (double)(g1 + g3)/2; else if(Math.abs(g2 - g3) <= t) grade = (double)(g2 + g3)/2; else grade = gj; System.out.printf("%.1f\n", grade); } }}
被这个题折磨了好久,一直都是Wrong Answer还找不到错误,最后发现又是不仔细,只注意了在最后一种情况下求平均数时转换double,没有注意到第一种情况也求了平均数,忘记了转换类型而一直出错。
题目1045:百鸡问题
题目描述:
用小于等于n元去买100只鸡,大鸡5元/只,小鸡3元/只,还有1/3元每只的一种小鸡,分别记为x只,y只,z只。编程求解x,y,z所有可能解。
输入:
测试数据有多组,输入n。
输出:
对于每组输入,请输出x,y,z所有可行解,按照x,y,z依次增大的顺序输出。
样例输入:
40
样例输出:
x=0,y=0,z=100
x=0,y=1,z=99
x=0,y=2,z=98
x=1,y=0,z=99
import java.util.*;public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int i,j,k,n,sum; //double sum; while(cin.hasNext()){ n = cin.nextInt(); for(i = 0 ; i <= n/5 ; i++){ for(j = 0 ; j <= n/3; j++){ sum = n - 5*i - 3*j; k = sum * 3; if( (i + j + k) >= 100){ k = 100 - i - j; System.out.printf("x=" + i + ",y=" + j + ",z=" + k + "\n"); } } } } }}
- 九度oj--1002和1045
- 九度 oj 1045
- 九度OJ-1002
- 九度OJ[1002]
- 九度OJ 1002
- 九度OJ 1002
- 九度OJ 1002 Grading
- 九度OJ 1002:grading
- 九度 OJ 1002 grading
- 【九度OJ】1002【模拟】
- 九度OJ 1002 Grading
- 【九度OJ--1002】grading
- 九度OJ 1002:Grading
- 九度oj-1002-Grading
- 九度 OJ 1002:Grading
- 九度OJ 题目1002
- 九度OJ 1002 Grading
- 九度OJ-1002:Grading
- 文件读写: 二进制方式和文本方式的区别
- 【LoadRunner】场景加压时,无法获取Windows服务器监控数据
- 《Windows程序设计》读书笔十二 剪贴板
- cs106a学习笔记 - 搭建Karel the robot环境
- 如何选择深度学习框架 TensorFlow/Torch/Mxnet/Theano
- 九度oj--1002和1045
- 【单片机执行指令的过程】
- 开始使用Log4j
- 软件 易用性理解
- 137.Your database instance is currently configured to support 1,500 connections. The Web application
- TextView自定义
- jQuery添加/筛选/检测(3)
- C++string类常用函数 c++中的string常用函数用法总结
- PHP接口开发