03-06-2012
For example, start with amountRemain=65, C1=25, C2=5.
First loop:
j = (65/C1) = (65/25) = 2 # Ignore the fraction
numcoin += j = (0 + j) = (0 + 2) = 2
amountRemain -= (j * C1) = 65 - (2*50) = 15
i.e. two coins of value 25.
Next loop:
j = (15 / C2) = (15 / 5) = 3
numCoin += 3 = (2 + 3) = 5
amountRemain -= (j * C2) = 15 - (3*5) = 0
Now, amountRemain is 0, so no more coins are needed.
In this method, it has calculated that, to pay 65 cents in quarters and nickels should take 2 quarters and 3 nickels, for a total of 5 coins.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
can some tell me how to do this. I mean, i tried finding this out on my own but when I checked the man pages, i got a truckload of commands available pertaining to this task which in turn got me confused.
so my question is, if there is a simple straight forward(not necessarily easy) way to... (2 Replies)
Discussion started by: TRUEST
2 Replies
2. Shell Programming and Scripting
Hi,
I'm a beginners, this is one of my first script, it's easy, but I don't know how to write this script:
The script receive in input 4 parameters:
1) user_name
2) r and/or w and/or x ( rwx, rw, x, ....)
3) u and/or g and/or o ( u, uo, ugo, ...)
4) the path name
The script print a... (2 Replies)
Discussion started by: DNAx86
2 Replies
3. Shell Programming and Scripting
hello, i have a lot of pcap files (tcpdump output) that i want to compare.
every tcpdump output has two file, server and client.
what i want to do is:
1. take timestamp, source address, destination address, and packet id from each file (server and client)
2. find the packets sent from... (0 Replies)
Discussion started by: slumpia
0 Replies
4. Shell Programming and Scripting
Hello,
I have two data (.txt) files which I need to do some operations on them simultaneously. for example:
file1:
word11 word12 word13
word21 word 22 word 23
word31 word32 word33
file2:
word11 word12 word13
word21 word 22 word 23
word31 word32 word33
I need to see if each... (13 Replies)
Discussion started by: shira
13 Replies
5. AIX
I have received errpt like this.Any help will be highly appreciated.Recently my application has been migrated to aix 5.3 and working fine in aix 5.2 with out crashes.
LABEL: CORE_DUMP
IDENTIFIER: C69F5C9B
Date/Time: Thu Apr 23 09:41:29 EDT 2009
Sequence Number: 948... (3 Replies)
Discussion started by: kittu1979
3 Replies
6. Emergency UNIX and Linux Support
We have a binary that generates coredump. So I ran the gdb command to analyze the issue. Pleae note the binary and code are in two different locations and we cannot build the whole binary using debugging symbols. Hence how and what details can I find from below backtarce:
gdb binary corefile
... (5 Replies)
Discussion started by: uunniixx
5 Replies
7. UNIX and Linux Applications
Is/Are there an/some application/applications , package/packages for benchmarking or system performance measuring which are there for almost all Linux releases and distributions? (2 Replies)
Discussion started by: nixhead
2 Replies
8. UNIX for Dummies Questions & Answers
Hi List,
Could someone please point me into the right direction with the following:
I have a file containing a list of street addresses.
I need to sort all the street addresses with the same number to a new file containing the street name and corresponding number.
So:
Strawinskylaan... (3 Replies)
Discussion started by: M474746
3 Replies
9. AIX
Hi Admins,
I need your help to analyze the cpu usage of our main server. I have shared below, CPU usages during busy hours and non busy hours.
CPU usage is always full at busy hours. Users always complaints about slowness. This server is a lpar partition and configured as uncapped mode.
... (7 Replies)
Discussion started by: newaix
7 Replies
10. AIX
Hi Guys,
I need some help analyzing the attached metrics. System context is 2 LPAR's in a P795 running WebSphere App Server across 4 nodes (2 on each LPAR).
Over the weekend both LPAR's lost power and upon re-start the application server response times have degraded by 25-30% for no obvious... (1 Reply)
Discussion started by: mgburns
1 Replies
GC(1) General Commands Manual GC(1)
NAME
gc - count graph components
SYNOPSIS
gc [ -necCaDUrs? ] [ files ]
DESCRIPTION
gc is a graph analogue to wc in that it prints to standard output the number of nodes, edges, connected components or clusters contained in
the input files. It also prints a total count for all graphs if more than one graph is given.
OPTIONS
The following options are supported:
-n Count nodes.
-e Count edges.
-c Count connected components.
-C Count clusters. By definition, a cluster is a graph or subgraph whose name begins with "cluster".
-a Count all. Equivalent to -encC
-r Recursively analyze subgraphs.
-s Print no output. Only exit value is important.
-D Only analyze directed graphs.
-U Only analyze undirected graphs.
-? Print usage information.
By default, gc returns the number of nodes and edges.
OPERANDS
The following operand is supported:
files Names of files containing 1 or more graphs in dot format. If no files operand is specified, the standard input will be used.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
1 The -U or -E option was used, and a graph of the wrong type was encountered.
AUTHOR
Emden R. Gansner <erg@research.att.com>
SEE ALSO
wc(1), acyclic(1), gvpr(1), gvcolor(1), ccomps(1), sccmap(1), tred(1), libgraph(3)
21 March 2001 GC(1)