Tuesday, December 11, 2012

Write a function to print all subsets of a certain size of the numbers from 1 to n


#include <iostream>
#include <stdio.h>

using namespace std;
const int MAX = 1000;
int a[MAX];
bool b[MAX];
void f1(int n, int k, int indexn, int indexk){
int i, j;
for(i = indexn; i <= n - k + indexk; i++){
if(!b[i]) {
b[i] = true;
a[indexk] = i;
if(indexk == k) {
for(j = 1; j <= k; j++) {
printf("%d ", a[j]);
}
printf("\n");
} else {
f1(n, k, indexn + 1, indexk + 1);
}
b[i] = false;
}
}
}
void f(int n, int k) {
int i;
for(i = 1; i <= n; ++i) {
a[i] = i;
b[i] = false;
}
f1(n, k, 1, 1);
}

int main()
{
    int n,k;
    while(scanf("%d %d",&n,&k) == 2)
    {
        f(n,k);
    }

return 0;
}

Friday, November 23, 2012

Unable to establish a secure connection to iTunes/iPhone

"Could not establish a secure connection to the device."

Here's what you have to do. You need a backup of your old Mac prior to upgrading, or prior to wiping and reinstalling.

You need to open Console on your new mac, and see the error message when you plug your phone into itunes and get that error, this will show up in your console:

8/13/12 1:21:04.537 PM iTunes[491]: AMDeviceValidatePairing (thread 0x11c313000): Could not load pairing record /var/db/lockdown//<device id>.plist

Then you need to go to your time machine backup and navigate to that same folder, and find the missing file. Copy that file back to your new machine into the /var/db/lockdown and you will magically be able to access your device again.

Tuesday, November 13, 2012

Make Xcode(4.x) faster


How to make  xcode faster
  • Buying more memory.
  • Disable indexing if you are building out huge projects in Xcode. This can halve Xcode’s memory consumption.
  • Running Xcode in 32 bit. This is not an option for everyone, because it will exceed 4 GB in larger projects.
  • Reduce the number of build processes (again).
  • Restarting Xcode often (It doesn’t do a very good job cleaning up after itself).
  • Use clang as your compiler. Clang instances in general use less memory than Apple’s GCC 4.2.
  • Offload dependent targets which do not change often. Example: You will not need to rebuild third party libraries daily in most cases.
Indexing in xcode
Xcode 4 has an entirely new mechanism for indexing files in a workspace. An index is created for the entire workspace, so references across projects are resolved.
The indexer now uses the LLVM compiler 2.0 to parse source files. This results in improved performance and higher accuracy; most importantly, the interpretation of symbols for indexing more closely matches the interpretation of syntax at compile time.
The index is stored in the Index subdirectory of the workspace’s unique directory in ~/Library/Developer/Xcode/DerivedData. Manage this information (including deleting the index and other derived data of an orphaned project) in the Organizer.
Indexing is done in the background; the Activity View indicates when indexing is being performed. Until the index is ready, some functions that require the index may not be available (for example, Open Quickly); others may have degraded performance (for example, syntax coloring of system symbols). When the index is complete these features become available immediately.
it seems to be that XCode4 and 4.1 uses crazy amounts of Ram during indexing - like, 5gb or so(!), and thus if you’re on a machine with something like 12gb, there’s no problem, but if you’re on a laptop with only 2gb or so, you’ll have some pretty severe paging going on.

How to disable indexing
Open the Terminal  window , then type the following code in terminal and click enter.
defaults write com.apple.dt.XCode IDEIndexDisable 1
Now restart your xcode and enjoy better performance.
How to Enable xcode indexing
if you upgraded your machine or you want some other features to be turned on if you need indexing service,  please follow the steps below.
Open the Terminal  window , then type the following code in terminal and click enter.
 defaults write com.apple.dt.XCode IDEIndexDisable 0
(or)
defaults delete com.apple.dt.XCode IDEIndexDisable
While you’re at it, you should delete the key you added as well:
defaults delete com.apple.dt.XCode IDEIndexEnable
Now restart the xcode now you can see the indexing will start from now on wards.
Disabling SVN & GIT in xcode
disabling SVN and Git plugins of XCode. Simply go to /Developer/Library/Xcode/PrivatePlugins
Now find IDEGit.ideplugin and IDESubversion.ideplugin
Change names of both of above plugins so that xcode will not be able to execute them in future. Now restart your xcode and enjoy better performance.

Monday, August 06, 2012

Install iOS 6 beta on your devices


You're now ready to start installing betas on your devices. To do this, you'll need to use the newest version of iTunes which is 10.6.3 or you can do this through the xCode 4.5 developer preview. I recommend that developers use the xCode method while app testers are probably okay using the iTunes method unless the developer would prefer you to use xCode to submit feedback.

iTunes method

This time around there is no beta version of iTunes needed. Just make sure you're running the current version of iTunes which is 10.6.3. You can download it from Apple's website.
  1. Open iTunes 10.6.3 after you've installed it and plug in the device you'd like to install iOS 6 beta to.
  2. Choose your device from the left navigation pane. You'll see a Restore button. Hold down Alt+option (or Ctrl for PC users) and click Restore.
  3. A file browser window will pop up. Navigate to the iOS 6 beta firmware file you would like to install onto your device.
  4. iTunes will now begin to update your device to iOS 6 beta. Let it do its thing and you're pretty much done.
  5. Xcode method

    1. In XCode, under software version, you'll need to choose Other version.
    2. Then xCode will ask you to navigate to the .ipsw file that you would like to install (the beta firmware file). I typically save them on my desktop or somewhere in a folder that I can easily find.
    3. Select it and click Restore iPhone
    4. A warning will pop up telling you all data will be erased. Agree and your device will be restored to the beta version. You can then restore from a backup in iTunes or from iCloud like you normally would.
    5. Either update method will get you onto the beta. It's up to you to decide what method is most appropriate for your situation.

      For more Check this.

Downgrade iOS 6 Beta to iOS 5.1.1


If you went ahead and installed iOS 6 beta and determined the buggy nature of the first developer release isn’t for you, it’s time to downgrade. Most developers should know how to do this already, but if not this process is easy and you’ll be back to running iOS 5.1.1 in no time at all.
Downgrading is identical on an iPhone, iPad, or iPod touch.
  1. Turn the device off, connect it to the computer via USB, and launch iTunes
  2. Place the iOS device into DFU mode: with the device off, hold down the Power and Home buttons together for 10 seconds then release the power button, continue holding Home button until iTunes notifies you of a device in recovery mode being detected. The devices screen should stay black as if turned off.
  3. Restore within iTunes through either method a or b:
    • a: Restore from the iOS 5.1.1 backup you made prior to installing iOS 6 beta
    • b: Restore to iOS 5.1.1 IPSW by Option-Clicking the “Restore” button, and then restore from iCloud backup when finished
  4. Let iTunes restore back to iOS 5.1.1, the device will reboot when finished
Typically you can’t downgrade iOS versions so easily, but because Apple is still signing iOS 5.1.1 this allows downgrading to commence with minimal effort.

Sunday, August 05, 2012

How to run multiple skype account at the same time in one computer


To use more than one Skype account on the same computer at the same time you need to start a new instance of Skype. 
  1. From the Windows taskbar, click Start > Run (or press the Windows and R keys on your keyboard at the same time) 
  2. In the Run window, enter the following command (include the quotes) and press OK:
    "C:\Program Files\Skype\Phone\Skype.exe" /secondary 
If you get an error message, copy and paste the exact command from this page and try again.
Be aware that if you have changed the installation path for Skype then you will need to enter the correct path for the Skype.exe file.
If this solution fails, you can try another option: 
  1. Find the Skype executable file (Skype.exe) in: C:\Program Files\Skype\Phone\ 
  2. Right click on it and select Send to > Desktop (create shortcut) 
  3. Locate the shortcut on the desktop, then right-click on it and select Properties 
  4. In the Target field, add: /secondary. The Target field should now be "C:\Program Files\Skype\Phone\Skype.exe" /secondary 
  5. Click OK. You can now start a new instance of Skype every time you double-click the new shortcut.

Sunday, March 25, 2012

PROGRAM TO FIND SQUARE ROOT OF A NUMBER - C CODE

#include<stdio.h>

float SquareRoot(float num);

int main()
{
    float input, ans;

    printf("\n Enter The Number : ");
    while(scanf("%f", &input) == 1)
    {
        ans = SquareRoot(input);
        printf("\n Square Root : %f\n", ans);
    }
    return 0;
}
float SquareRoot(float num)
{
    if(num >= 0)
    {
        float x = num;
        int i;
        for(i = 0; i < 20; i ++)
        {
            x = (((x * x) + num) / (2 * x));
        }
        return x;
    }
}

Wednesday, February 08, 2012

Web page Downloader in Java ( Basic URL connection) like facebook

/*
 * @(#)DownloadPage.java
 *
 *
 * @author Md. Saiful Islam
 * @Reg    :   2005331074
 * @version 1.00 2010/7/29
 */


import java.awt.*;
import java.io.*;
import java.net.InetAddress;
import java.net.*;
import java.util.*;
import java.math.*;
import java.lang.*;

public class DownloadPage
{      
    public DownloadPage() { }
   
    public static void main(String[] args)  throws  IOException
    {    
       
URL url;
InputStream is = null;
DataInputStream dis;
String Link,line,PageName;


Link = "http://www.facebook.com/";
FileOutputStream fileOutput;
PageName = "Download.html";



File file = new File(PageName);
file.createNewFile();
fileOutput = new FileOutputStream(file);



try
{
   url = new URL(Link);
 
   is = url.openStream();
   dis = new DataInputStream(new BufferedInputStream(is));

   while( ( line = dis.readLine() ) != null )
   {
       System.out.println(line);      
       fileOutput.write(line.getBytes());
   }
 
}

catch ( MalformedURLException waste )
{
    waste.printStackTrace();
}

catch ( IOException input )
{
    input.printStackTrace();
   }
 
finally
{

   try
   {
       is.close();
   }
    catch (IOException ioe)
    {
   
    }
} // End of finally
   
    } // End of main class
   
} // End of DownloadPage class

Topological Sort With Back Edge Or Cycle( UVA - 11686)

/***
    Topological Sort With Back Edge Or Cycle
    Author : Md.Saiful Islam
***/
#include<stdio.h>
#include<vector>
#define mm 100000
using namespace std;


long ff,k,Node,Edge,a,b,x,aa[mm],flag[mm], tag;


vector< long >adjlist[mm];


void dfs_visit(long x)
{
    long i;
    flag[x] = 1;


    for(i = 0; i < adjlist[x].size(); i++)
    {
        ff=adjlist[x].at(i);
        if(flag[ff] == 0)
            dfs_visit(adjlist[x][i]);
        else if(flag[ff] == 1)
            tag = 1;
    }
    aa[k++] = x;
    flag[x] = 2;
}


int main()
{
    long i;
    while(scanf("%ld %ld",&Node,&Edge)==2 && (Node || Edge))
    {
        for(i=0;i<Node;i++)
        {
            flag[i] =0;
            adjlist[i].clear();
        }


        for(i=0;i<Edge;i++)
        {
            scanf("%ld %ld",&a,&b);
            adjlist[a-1].push_back(b-1);
        }
        tag = 0; k=0;
        for(i = 0;i < Node; i++)
        {
            if(flag[i] == 0)
            dfs_visit(i);
        }
        if(tag == 1)
        {
            printf("IMPOSSIBLE\n");
            continue;
        }
        else
        {
            for(i=k-1;i>=0;i--)
                printf("%ld\n",aa[i]+1);
        }
    }
    return 0;
}

Topological Sort (10305 - Ordering Tasks)

/***
Topological Sort
Author : Md.Saiful Islam
***/


#include<stdio.h>
#include<stdlib.h>


int Node,Edge,adjlist[102][102],a,b,start,i,x,front;
bool flag[110];
void dfs_visit(int x)
{
if( !flag[x])
{
flag[x] = 1;


for(i = 1;i <= adjlist[x][0];i++)
dfs_visit(adjlist[x][i]);


start++;
if(start != Node) printf("%d ",x);
else printf("%d",x);
}
}


int main()
{
while(scanf("%d%d",&Node,&Edge)==2 && (Node || Edge))
{
for(i=0;i<Edge;i++)
{
scanf("%d %d",&a,&b);
adjlist[b][++adjlist[b][0]] = a;
}
start = 0;


for(front = 1;front <= Node; front++)
dfs_visit(front);


for(i=1;i<=Node;i++)
adjlist[i][0] = flag[i] = 0;
printf("\n");
}
return 0;
}

Strongly Connected Component

/***
    Strongly Connected Component
    Author : Md.Saiful Islam
***/
#include<iostream>
#include<vector>
#define sz 10001
using namespace std;


vector<int>adj[sz];
int Node,Edge,u,v,array[sz],top,r;
bool Flag[sz];


void DFS(int u,bool s)
{
    if(Flag[u] == s) return;
    Flag[u]= s;
    for(int i=0;i<adj[u].size();i++)
        DFS(adj[u][i],s);
    if(s) array[top--]=u;
    return;
}


int main()
{
    int i,j,test,cnt,kase=1;
    scanf("%d",&test);
    while(test--)
    {
        scanf("%d %d",&Node,&Edge);
        for(i=1;i<=Edge;i++)
        {
            scanf("%d %d",&u,&v);
            adj[u].push_back(v);
        }
        top=Node; cnt=0;
        for(i=1;i<=Node;i++)
            if(!Flag[i])
                DFS(i,true);


        for(i=1;i<=Node;i++)
        {
            if( Flag[ array[i] ] )
            {
                DFS( array[i] , false );
                cnt++;
            }
            adj[ array[i] ].clear();
        }
        printf("Case %d: %d\n",kase++,cnt);
        for(i=0;i<=Node;i++)Flag[i] = false;
    }
    return 0;
}
/*
Input:
3
5 4
1 2
1 3
3 4
5 3


4 4
1 2
1 3
4 2
4 3


3 2
1 2
2 3
Output:
Case 1: 2
Case 2: 2
Case 3: 1
*/

Second Best MST (UVA 10462 - Is there any second way)

/***
    Second Best MST (UVA 10462 - Is there any second way)
    Author : Md.Saiful Islam
***/
#include<stdio.h>
#include<stdlib.h>
#define INF 99999999


struct S
{
int u,v,cost;
};
S a[203];


int Set[203],Rank[203],store[203];
int Node,Edge;


void make_set(int x)
{
Set[x] = x;
Rank[x] = 0;
}
int find_set(int x)
{
if(x != Set[x])
{
Set[x] = find_set(Set[x]);
}
return Set[x];
}


void Union(int x,int y)
{
if(Rank[x] > Rank[y])
{
Set[y] = x;
}
else
{
Set[x] = y;
if(Rank[x] == Rank[y])
{
Rank[y]++;
}
}
return;
}


int comp_fun(const void *m,const void *n)
{
S *x,*y;
x=(S*)m;
y=(S*)n;
return ( x->cost - y->cost );
}
int main()
{
int i,u_set,v_set,sum,set,test,ans,k,min,cnt,y,kase=1;


scanf("%d",&test);
while(test--)
{
scanf("%d %d",&Node,&Edge);
set  = 0;
for(i=0;i<=Node;i++)
{
make_set(i);
}
ans = -1;
for(i=0;i<Edge;i++)
{
   scanf("%d %d %d",&a[i].u,&a[i].v,&a[i].cost);
}


qsort(a,Edge,sizeof(S),comp_fun);


sum = k = 0;
for(i=0; i<Edge ;i++)
{
u_set=find_set(a[i].u);
v_set=find_set(a[i].v);
if( u_set!=v_set )
{
store[k++]=i;
sum += a[i].cost;
Union(u_set,v_set);
}
}


// second best MST start here
//if(k >= Node-1)ans = sum; // First MST Cost


min = INF;


for(y=0;y<k;y++)
{
sum = 0;
for(i=0;i<=Node;i++)
{
make_set(i);
}
for(i=cnt=0;i<Edge;i++)
{
if(store[y] != i)
{
u_set=find_set(a[i].u);
v_set=find_set(a[i].v);
if( u_set!=v_set )
{
cnt++;
sum += a[i].cost;
Union(u_set,v_set);
}
}
}
if(cnt >= Node-1 && sum < min) min = sum;
}
if(ans == -1)printf("Case #%d : No way\n",kase++);
else if(min == INF)printf("Case #%d : No second way\n",kase++);
else printf("Case #%d : %d\n",kase++,min);
}
return 0;
}
/*
Input:
4
5 4
1 2 5
3 2 5
4 2 5
5 4 5
5 3
1 2 5
3 2 5
5 4 5
5 5
1 2 5
3 2 5
4 2 5
5 4 5
4 5 6
1 0
Output:
Case #1 : No second way
Case #2 : No way
Case #3 : 21 // second best cost
Case #4 : No second way
*/

Minimum Spanning Tree (Prims Algorithm)

/***
    Minimum Spanning Tree (Prims Algorithm)
    Author : Md.Saiful Islam
***/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>


using namespace std;


#define SIZE 10000


struct pq
{
int cost,node;
bool operator<(const pq &b)const
{
return cost>b.cost;    // Min Priority Queue
}
};


int Prims(vector<pq>adj[],int source,int nodes)
{
priority_queue<pq>Q;
vector<int>color(nodes);
pq U,V;
int i,sum;


V.node=source;
sum=V.cost=0;
Q.push(V);
while(!Q.empty())
{
U=Q.top();
if(color[U.node]==0)
            sum+=U.cost;
color[U.node]=1;
Q.pop();
for(i=0;i<adj[U.node].size();i++)
{
if(color[ adj[U.node][i].node]==0)
{
V.node=adj[U.node][i].node;
V.cost=adj[U.node][i].cost;
Q.push(V);
}
}
}
return sum;
}


int main()
{
int nodes,edges,i,u,v,cost,source,val;
pq V;
vector<int>dist;
vector<pq>adj[SIZE];


while(scanf("%d %d",&nodes,&edges)==2)
{
for(i=0;i<nodes;i++)
{
adj[i].clear(); //clear adj vector
}
for(i=0;i<edges;i++)
{
scanf("%d %d %d",&u,&v,&cost);
V.cost=cost;
V.node=v;
adj[u].push_back(V);
V.node=u; //For Bidirectional Edges
adj[v].push_back(V);
}
val=Prims(adj,0,nodes);
printf("%d\n",val);
}


return 0;
}
/*
    Input:
    5 7
    0 1 5
    0 2 4
    1 2 2
    1 4 3
    2 4 1
    2 3 4
    3 4 3
    Output:
    10
*/

Minimum spanning tree Kurskal Using MAP + String

/***
    MST - Kurskal Using MAP + String
    UVA - 11710 Expensive Subway
    Author : Md.Saiful Islam
***/
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
int cnt,i,node,edge,sum,u,v,cost;
int rank[410],parent[410],array[79810][3];
char str[15];


map<string,int>flag;


int cmp(const void *a,const void *b)
{
   int *x = (int *) a;
   int *y = (int *) b;
   return *x - *y;
}


int Find_Set(int x)
{
if(x != parent[x] )
parent[x]=Find_Set(parent[x]);
    return parent[x];
}


void Link(int x,int y)
{
if(rank[x]>rank[y]) parent[y]=x;


else
{
parent[x]=y;


if(rank[x]==rank[y])    rank[y]=rank[y]+1;
    }
}


int main()
{
    while(scanf("%d %d",&node,&edge)==2 && (node || edge))
    {
        for(i=0;i<node;i++)
        {
            scanf("%s",str);
            flag[str]=i+1;
            parent[i]=i;
            rank[i]=0;
        }
        sum = cnt = 0;
        for(i=0;i<edge;i++)
        {
            scanf("%s",str);
            u = flag[str]-1;
            scanf("%s",str);
            v = flag[str]-1;
            scanf("%d",&cost);
            array[i][0]=cost;array[i][1] = u; array[i][2] = v;
        }
        qsort(array,edge,sizeof(array[0]),cmp);
        for(i=0;i<edge;i++)
        {
            u = array[i][1];
            v = array[i][2];
            cost = array[i][0];
            u = Find_Set(u);
            v = Find_Set(v);


            if(u!=v)
            {
                Link(u,v);
                cnt++;
                sum+=cost;


            }
        }
        scanf("%s",str);
        if(cnt!=node-1)
            printf("Impossible\n");
        else printf("%d\n",sum);
        flag.clear();
    }
    return 0;
}
/*
Input:
3 3
Picadilly
Victoria
Queensway
Picadilly Victoria 2
Queensway Victoria 10
Queensway Picadilly 20
Picadilly
4 2
Picadilly
Victoria
Queensway
Temple
Picadilly Victoria 2
Temple Queensway 100
Temple
Output:
12
Impossible
*/

Normal Kurskal algorithm (Cordinate Given)

/***
    Normal Kurskal (Cordinate Given)
    Author : Md.Saiful Islam
***/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define Node_num 10004

struct S
{
int u,v,cost;
};
S a[Node_num];

int Set[Node_num],Rank[Node_num];
int Node,Edge;
double x[10003],y[10003];

void make_set(int x)
{
Set[x] = x;
Rank[x] = 0;
}

int find_set(int x)
{
if(x != Set[x])
{
Set[x] = find_set(Set[x]);
}
return Set[x];
}

void Union(int x,int y)
{
if(Rank[x] > Rank[y])
{
Set[y] = x;
}
else
{
Set[x] = y;
if(Rank[x] == Rank[y])
{
Rank[y]++;
}
}
return;
}

int comp_fun(const void *m,const void *n)
{
S *x,*y;
x=(S*)m;
y=(S*)n;
return ( x->cost - y->cost );
}

int main()
{
int  test,n,k,i,j,u_set,v_set,flag;
double sum,t1,t2;

scanf("%d",&test);
while(test--)
{
flag = 1;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%lf %lf",&x[i],&y[i]);
k=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{

a[k].u=i+1,a[k].v=j+1;
t1=x[i]-x[j],t2=y[i]-y[j];
a[k].cost = t1*t1 + t2*t2;
k++;

}
}

qsort(a,k,sizeof(S),comp_fun);

for(i=0;i<=n;i++)
{
make_set(i);
}

sum = 0.0;
for(i=0; i<k ;i++)
{
u_set=find_set(a[i].u);
v_set=find_set(a[i].v);
if(u_set!=v_set)
{
sum += sqrt(a[i].cost);
Union(u_set,v_set);
flag = 0;
}
}
printf("%.2lf\n",sum);
if(test)
printf("\n");
}
return 0;
}
/*
Input:
1

3
1.0 1.0
2.0 2.0
2.0 4.0
Output:
3.41
*/

Tuesday, February 07, 2012

MST - Kurskal Algorithm

/***
    MST - Kurskal Algorithm
    Author : Md.Saiful Islam
***/
#include<stdio.h>
#include<stdlib.h>


struct S
{
int u,v,cost;
};
S a[10002];


int Set[1002],Rank[1002];
int Node,Edge;


void make_set(int x)
{
Set[x] = x;
Rank[x] = 0;
}
int find_set(int x)
{
if(x != Set[x])
{
Set[x] = find_set(Set[x]);
}
return Set[x];
}


void Union(int x,int y)
{
if(Rank[x] > Rank[y])
{
Set[y] = x;
}
else
{
Set[x] = y;
if(Rank[x] == Rank[y])
{
Rank[y]++;
}
}
return;
}


int comp_fun(const void *m,const void *n)
{
S *x,*y;
x=(S*)m;
y=(S*)n;
return ( y->cost - x->cost );
}
int main()
{
int i,taken,u_set,v_set,test,kase=1,max;


scanf("%d",&test);
while(test--)
{
scanf("%d %d",&Node,&Edge);


for(i=0;i<Edge;i++)
{
   scanf("%d %d %d",&a[i].u,&a[i].v,&a[i].cost);
}
qsort(a,Edge,sizeof(S),comp_fun);


for(i=0;i<Node;i++)
{
make_set(i);
}


taken=1;max = 99999999;
for(i=0; taken<Node ;i++)
{
u_set=find_set(a[i].u);
v_set=find_set(a[i].v);
if( u_set!=v_set )
{
++taken;
if(a[i].cost <= max)
max = a[i].cost;
Union(u_set,v_set);
}
}
printf("Case #%d: %d\n",kase++,max);
}
return 0;
}
/*
Input:
2
2 3
0 1 10
0 1 20
0 0 30
4 5
0 1 1
3 1 2
1 2 3
2 3 4
0 2 5
Output:
Case #1: 20
Case #2: 3
*/