## 12190 - Electric Bill

All about problems in Volume 121. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### 12190 - Electric Bill

Use this thread to discuss this problem.
Check input and AC output for thousands of problems on uDebug!

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 12190 - Electric Bill

Test data generator.

Code: Select all

``````#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <ctime>
#include <cstdlib>

using namespace std;

int fee(int watt)
{
int cost = 0;
if (watt > 1000000) { cost += (watt - 1000000) * 7; watt = 1000000; }
if (watt >= 10001) { cost += (watt - 10000) * 5; watt = 10000; }
if (watt >= 101) { cost += (watt - 100) * 3; watt = 100; }
cost += watt * 2;
return cost;
}

int main(int argc, char *argv[])
{
srand(time(NULL));

int watta, wattb, feea, feeb;
for (int i = 1; i <= 100; i++)
{
do
{
watta = rand() % 100000000 + 1;
feea = fee(watta);
wattb = rand() % 100000000 + 1;
feeb = fee(wattb);
} while (fee(watta + wattb) > 1e9);

cout << fee(watta + wattb) << ' ' << abs(feea - feeb) << '\n';
}
cout << "0 0\n";

return 0;
}
``````