fork download
  1. import java.util.Scanner;
  2. class MyClass{
  3.  
  4. public static void main(String[] args){
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. int N = sc.nextInt();
  8.  
  9. double happy = N;
  10. double sad = 0;
  11.  
  12. for(int i=0; i<=4 ; i++){
  13. double newHappy = happy * 0.3 + sad * 0.5;
  14. double newSad = happy * 0.7 + sad * 0.5;
  15. happy = newHappy;
  16. sad = newSad;
  17. }
  18. System.out.println(Math.round(happy) + " " + Math.round(sad));
  19. }
  20. }
Success #stdin #stdout 0.14s 58700KB
stdin
2000
836 1164
stdout
833 1167