fork(1) download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int computervirus(int n){ //n:Tage
  6. int nr_virus= 100;
  7. int nr_fixed = 0;
  8. int rest = 0;
  9.  
  10. if(n>0){
  11. nr_virus = computervirus(n-1)*1.7;
  12. if (n==1)
  13. nr_fixed = 2;
  14. else nr_fixed = pow(2,n-1);
  15. }
  16. rest = nr_virus - nr_fixed;
  17. if (rest<0)
  18. rest = 0;
  19. return rest;
  20. }
  21.  
  22. int main(){
  23.  
  24. for(int i=0; i <= 20; i++){
  25. cout << endl;
  26. cout << "at the "<< i << " .day are still "<< computervirus(i) << " infected Computers\n" <<endl;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
at the 0 .day are still 100 infected Computers


at the 1 .day are still 168 infected Computers


at the 2 .day are still 283 infected Computers


at the 3 .day are still 477 infected Computers


at the 4 .day are still 802 infected Computers


at the 5 .day are still 1347 infected Computers


at the 6 .day are still 2257 infected Computers


at the 7 .day are still 3772 infected Computers


at the 8 .day are still 6284 infected Computers


at the 9 .day are still 10426 infected Computers


at the 10 .day are still 17212 infected Computers


at the 11 .day are still 28236 infected Computers


at the 12 .day are still 45953 infected Computers


at the 13 .day are still 74024 infected Computers


at the 14 .day are still 117648 infected Computers


at the 15 .day are still 183617 infected Computers


at the 16 .day are still 279380 infected Computers


at the 17 .day are still 409410 infected Computers


at the 18 .day are still 564925 infected Computers


at the 19 .day are still 698228 infected Computers


at the 20 .day are still 662699 infected Computers