Problem 1. Anonymous Downsite
+ Нов въпрос
gina78 avatar gina78 6 Точки

Anonymous Downsite

здравейте, тая задаа не мога да разбера какво трябва да закръгля

това е кода ми

Judge ми дава 30/100

Problem 1. Anonymous Downsite

The Anonymous informal group of activists have hacked a few commercial websites and the CIA has hired you to write a software which calculates the losses. Based on the given data, use the appropiate data types.

You will receive 2 input lines – each containing an integer.

  • The first is N – the number of websites which are down.
  • The second is the security key.

On the next N lines you will receive data about websites in the following format:
{siteName} {siteVisits} {siteCommercialPricePerVisit}

You must calculate the site loss by the following formula: siteVisits * siteCommercialPricePerVisit

When you finish reading all data, you must print the affected sites’ names – each on a new line.
Then you must print the total money loss – sum of all site loss, on a new line.
Finally you must print the security token, which is the security key, POWERED by the COUNT of affected sites.


  • On the first input line you will get N – the count of affected websites.
  • On the second input line you will the security key.
  • On the next N input lines you will get data about the websites.


As output you must print all affected websites’ nameseach on a new line.

After the website names you must print the total loss of data, printed to the 20th digit after the decimal point. The format is “Total Loss: {totalLoss}”.

Finally you must print the security token. The format is “Security Token: {securityToken}”.


The integer N will be in range [0, 100].

The security token will be in range [0, 10].

The website name may contain any ASCII character except whitespace.

The site visits will be an integer in range [0, 231].

The price per visit will be a floating point number in range [0, 100] and will have up to 20 digits after the decimal point.

  • Allowed working time/memory: 100ms / 16MB.





8 122300 94.23233 2333 11 12322 23.3222

Total Loss: 11837653.10740000000000000000

Security Token: 512


1 100000 10.45

Total Loss: 1045000.00000000000000000000

Security Token: 1

Remember, remember!

The fifth of November...

PHP Fundamentals
willystyle avatar willystyle 1883 Точки

Тая задача е трудна на PHP и JS, в C# и Java ползват decimal и BigInteger и се оправят, но тук без външни библиотеки го докарвам едва до 90:

$n = intval(readline());
$securityKey = intval(readline());
$totalLoss = 0;
$token = bcpow($securityKey, $n);
for ($i = 0; $i < $n; $i++) {
    $visits = explode(" ", readline());
    echo "$visits[0]" . PHP_EOL;
    $siteVisits = intval($visits[1]);
    $siteCommercialIncomePerVisit = floatval($visits[2]);
    $totalLoss +=  $siteCommercialIncomePerVisit * $siteVisits;
printf("Total Loss: %.5f" . str_repeat("0", 15) . PHP_EOL, $totalLoss);
echo "Security Token: $token" . PHP_EOL;


gina78 avatar gina78 6 Точки

благодаря ти мого