/*
ID: sdjllyh1
PROG: beads
LANG: C++
complete date: 2008/9/8
efficiency: O(n^2)
author: LiuYongHui From GuiZhou University Of China
more article: www.cnblogs.com/sdjl
*/
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//打断的珠子类(直线形)
class BROKEN_NECKLACE
;//end class BROKEN_NECKLACE
//完整的珠子类(环形)
class NECKLACE
;//end class NECKLACE
//main program start
int best = 0;//记录获得的珠子数的最大值
NECKLACE *necklace;
void Init()
{
ifstream fin ("beads.in");
int n;
string beads;
fin>>n;
fin>>beads;
necklace = new NECKLACE(beads);
fin.close();
}
void Run()
{
for(int i=0; i<necklace->GetLength(); i++)
{
BROKEN_NECKLACE bNecklace = necklace->Break(i);
best = max(best,bNecklace.GetBeadsFromBothSides());
}
}
void Show()
{
ofstream fout ("beads.out");
fout<<best<<endl;
fout.close();
}
void UnInit()
{
delete necklace;
}
int main()
{
Init();
Run();
Show();
UnInit();
return 0;
}
ID: sdjllyh1
PROG: beads
LANG: C++
complete date: 2008/9/8
efficiency: O(n^2)
author: LiuYongHui From GuiZhou University Of China
more article: www.cnblogs.com/sdjl
*/
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//打断的珠子类(直线形)
class BROKEN_NECKLACE
;//end class BROKEN_NECKLACE
//完整的珠子类(环形)
class NECKLACE
;//end class NECKLACE
//main program start
int best = 0;//记录获得的珠子数的最大值
NECKLACE *necklace;
void Init()
{
ifstream fin ("beads.in");
int n;
string beads;
fin>>n;
fin>>beads;
necklace = new NECKLACE(beads);
fin.close();
}
void Run()
{
for(int i=0; i<necklace->GetLength(); i++)
{
BROKEN_NECKLACE bNecklace = necklace->Break(i);
best = max(best,bNecklace.GetBeadsFromBothSides());
}
}
void Show()
{
ofstream fout ("beads.out");
fout<<best<<endl;
fout.close();
}
void UnInit()
{
delete necklace;
}
int main()
{
Init();
Run();
Show();
UnInit();
return 0;
}