2014
02-14

# On-Line Banking

A central bank is an institution that is responsible for the monetary policy of a country. Beside others, it monitors and supervises other banks. Your task is to write a computer program that will serve as a simple supervision instrument for monitoring bank accounts.

The input contains several scenarios. Each scenario begins with a line containing a single positive integer A, the number of bank accounts at the beginning of the supervision, 0 < A ≤ 100. Then there are A lines each describing one account. Such a line contains the account number, one space, and a non-negative decimal number specifying the account balance.

Each of the following lines specifies a request for one bank operation. The line begins with a command and then, separated by a space, there are optional parameters. The list of commands follows, the third column in the table shows the number of parameters.

The number of requests in every scenario will always be between 0 and 1000 (inclusive). The last request of a scenario is followed by the word "end" and one empty line. Then the next scenario begins. The last scenario is followed by a line containing zero in place of A.

All account numbers consist of exactly four decimal digits followed by a slash character ("/") and one digit specifying a code of the bank that operates the account. Each bank has its own unique code.

Amounts are always given as non-negative decimal numbers with exactly two digits after the decimal point. No amount in the input will be higher than 10 000. No unnecessary leading zeros are permitted, i.e., only amounts strictly less than 1.00 may start with a zero.

The input contains several scenarios. Each scenario begins with a line containing a single positive integer A, the number of bank accounts at the beginning of the supervision, 0 < A ≤ 100. Then there are A lines each describing one account. Such a line contains the account number, one space, and a non-negative decimal number specifying the account balance.

Each of the following lines specifies a request for one bank operation. The line begins with a command and then, separated by a space, there are optional parameters. The list of commands follows, the third column in the table shows the number of parameters.

The number of requests in every scenario will always be between 0 and 1000 (inclusive). The last request of a scenario is followed by the word "end" and one empty line. Then the next scenario begins. The last scenario is followed by a line containing zero in place of A.

All account numbers consist of exactly four decimal digits followed by a slash character ("/") and one digit specifying a code of the bank that operates the account. Each bank has its own unique code.

Amounts are always given as non-negative decimal numbers with exactly two digits after the decimal point. No amount in the input will be higher than 10 000. No unnecessary leading zeros are permitted, i.e., only amounts strictly less than 1.00 may start with a zero.

3
1234/5 100.00
4321/6 150.20
5432/5 1600.00
withdraw 1234/5 20.00
deposit 1234/5 35.00
withdraw 1234/5 200.00
transfer 5432/5 1234/5 100.50
transfer 5432/5 4321/6 50.00
create 1234/5
create 1236/5
transfer 1236/5 1236/5 100.00
transfer 1236/5 1234/5 100.00
withdraw 0000/0 100.00
deposit 0000/0 0.11
transfer 1234/5 0000/0 10000.00
end

1
9999/9 9.40
deposit 9999/9 6.92
withdraw 9999/9 9.68
withdraw 9999/9 6.64
end

0

withdraw 20.00: ok
deposit 35.00: ok
withdraw 200.00: insufficient funds
transfer 100.50: ok
transfer 50.00: interbank
create: ok
transfer 100.00: same account
transfer 100.00: insufficient funds
withdraw 100.00: no such account
deposit 0.11: no such account
transfer 10000.00: no such account
end

deposit 6.92: ok
withdraw 9.68: ok
withdraw 6.64: ok
end

goodbye

The Game

 Time limit: 1sec. Submitted: 177 Memory limit: 64M Accepted: 112

Source: ulm

 There are n bowls, numbered from 1 to n. Initially, bowl i contains mi marbles. One game step consists of removing one marble from a bowl. When removing a marble from bowl i (i > 1), one marble is added to each of the first i-1 bowls; if a marble is removed from bowl 1, no new marble is added. The game is finished after each bowl is empty. Your job is to determine how many game steps are needed to finish the game. You may assume that the supply of marbles is sufficient, and each bowl is large enough, so that each possible game step can be executed. Input Specification The input contains several test cases. Each test case consists of one line containing one integer n (1 �� n �� 50), the number of bowls in the game. The following line contains n integers mi (1 �� i �� n, 0 �� mi �� 1000), where mi gives the number of marbles in bowl i at the beginning of the game. The last test case is followed by a line containing 0. Output Specification For each test case, print one line with the number of game steps needed to finish the game. You may assume that this number fits into a signed 64-bit integer (in C/C++ you can use the data type “long long”, in JAVA the data type “long”). Sample Input   10 3 3 3 3 3 3 3 3 3 3 5 1 2 3 4 5 0    Sample Output   3069 129 

#include <iostream>

using
namespace std;

int
main(int argc, char** argv) {

int n;

while (cin >> && n) {

long long step 0;

long long m;

cin >> m;

step += m;

long long p=1;

for (int 1n; i++) {

cin >> m;

*=
2;

step += m;

}

cout << step << endl;

}

return 0;

}

1. /*
* =====================================================================================
*
* Filename: 1366.cc
*
* Description:
*
* Version: 1.0
* Created: 2014年01月06日 14时52分14秒
* Revision: none
* Compiler: gcc
*
* Author: Wenxian Ni (Hello World~), niwenxianq@qq.com
* Organization: AMS/ICT
*
* =====================================================================================
*/

#include
#include

using namespace std;

int main()
{
stack st;
int n,i,j;
int test;
int a[100001];
int b[100001];
while(cin>>n)
{
for(i=1;i>a[i];
for(i=1;i>b[i];
//st.clear();
while(!st.empty())
st.pop();
i = 1;
j = 1;

while(in)
break;
}
while(!st.empty()&&st.top()==b[j])
{
st.pop();
j++;
}
}
if(st.empty())
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}

2. #!/usr/bin/env python
def cou(n):
arr =
i = 1
while(i<n):
arr.append(arr[i-1]+selfcount(i))
i+=1
return arr[n-1]

def selfcount(n):
count = 0
while(n):
if n%10 == 1:
count += 1
n /= 10
return count