HDU 2570 写在这里,提醒自己不要粗心。。。。。。。
2013-04-03 21:39
597 查看
import java.util.Scanner; import java.util.Arrays; public class Main { int n; int v; int w; int[] a; Main( int n,int v,int w ) { this.n = n; this.v = v; this.w = w; this.a = new int ; } public void setA( int i,int b ) { this.a[i] = b; } public void getM() { Arrays.sort( this.a ); int k = 0; int sum = 0; int f = this.w; for( int i=0;i<this.n;i++ ) { sum += this.a[i]; if( sum>this.w ) { sum -= this.a[i]; break; } else { k++; this.w += f; } } if( k>0 ) { double c = sum*0.01/k; System.out.print( k*this.v + " " ); System.out.printf( "%.2f",c ); System.out.println(); } else { System.out.println( "0 0.00" ); } } public static void main(String[] args) { int n=0; Scanner s = new Scanner(System.in); int c=0; c = s.nextInt(); int v=0; int w=0; while( c>0 ) { n = s.nextInt(); v = s.nextInt(); w = s.nextInt(); Main m = new Main( n,v,w ); for( int i=0;i<n;i++ ) { int b = s.nextInt(); m.setA( i,b ); } m.getM(); c--; } } }
唉,确实还是太粗心了。。。。。。
提醒自己不要粗心。。。。。。
相关文章推荐
- 关于创业僵尸 -- 很早之前转过,放在这里提醒自己不要松懈
- 用c++builder6.0开发小闹钟(用于提醒自己不要盯着屏幕太久)
- 用c++builder6.0开发小闹钟(用于提醒自己不要盯着屏幕太久)
- 提醒自己一下:不要浮躁!
- HDU 3359 提醒下自己!!
- 发现自己基础很差,提醒自己不要轻视简单代码!
- 提醒自己:把握好自己前进的方向和目标,不要"误入歧途"
- 不要做浮躁的程序员,时刻提醒自己
- 【原创】提醒久坐器:一个小时提醒一次,让自己不要长时间坐在椅子上
- 使用多线程方法实现一个死锁程序,用来提醒自己不要犯这样的错误
- 这段程序还搞错一个输出(写在这里提醒自己)
- 在这里记录自己成长的点滴
- 不要相信权威 永远相信自己的判断
- 自己不要怪谁。是你自己努力的程度不够,努力吧!
- 相信在这里会找到自己需要的……
- 提醒自己每次写代码都应该记住的一些点(更新中...)
- HDU 2089 不要62(挖个坑=-=)
- 以后经常在这里谈谈自己编程的心得
- 如果要重复的间隔一段固定的时间做同一件事, 如何提醒自己来做这机械的事呢?
- HDU 2089 不要62(数位DP)