المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : سؤال جديد .. على نمط اسئلة مسابقة acm يلا شعب المسابقه يشدوا حيلهم


عالم الحاسوب
26 - 02 - 2009, 15:38
مساء / صباح الورد


عندي عنا سؤال .. هذا السؤال كان من ضمن اسئلة مسابقة ACM للعام 2007 .. عن نفسي بعدني ما كملت الحل :ee: .. و كل واحد يشاركنا بفكره أو بالحل النهائي اذا وصل له

Description
We want to build the tallest skyscraper possible on our lot. We need to satisfy the following requirements:

* Each floor's area must be a whole number.
* The bottom floor has to fit on our lot.
* Each floor's area will be less than or equal to 4/5 of the area of the floor below it.

Given the lot size determine the maximum number of floors we can have in our skyscraper.

Input
Each line gives the area of a lot. It will be between 1.0 and 100,000.0

Output
Output the problem number and the maximum number of floors using the format shown below. The end of input will be signaled by a line containing -1.0
========== Example ==========
The first building can have its bottom floor area be 3 which can support a floor with an area of 2 which can support a floor with an area of 1. So the first building can have at most 3 floors.
Example Input
3.2
17321.2
-1.0
Example Output
Problem 1: 3
Problem 2: 40





السؤال فكرته بسيطه :mt:
تحياتي .. عالم الحاسوب

Mazin
26 - 02 - 2009, 16:28
#include <iostream>
using namespace std;

int main ()
{
double num;
int count1=0,count2=0;

while(1)
{
cin >> num;
int hold = num;

count1++;

if(num == -1.0)
exit(1);

while(hold>0)
{
hold = (hold*4/5);
count2++;
}

cout << "Problem " << count1 << " : " << count2 << endl;
count2=0;
}


return 0;
}


القراءة من الكيبورد عشان testing .. بس يحتاج تعديل بسيط ويصير من الملف .. :icon26:

Mazin
26 - 02 - 2009, 17:03
#include <fstream>
using namespace std;

int main ()
{
ifstream input("skyscraper.in");
ofstream output("skyscraper.txt");
double num;
int count1=0,count2=0;

while(1)
{
input >> num;
int hold = num;

count1++;

if(num == -1.0)
exit(1);

while(hold>0)
{
hold = (hold*4/5);
count2++;
}

output << "Problem " << count1 << " : " << count2 << endl;
count2=0;
}


return 0;
}


وهذا input و output في الملف مثل نظام المسابقة

بس يحتاج ملف اسمه skyscraper.in ويكون فيه inputs

عالم الحاسوب
27 - 02 - 2009, 14:53
<< سويت فورمات للابتوب و راح الحل مالي :crash:

بشوفه بكومبيوتري بالقسم اذا في نسخه :fk:

Mazin
27 - 02 - 2009, 15:01
<< سويت فورمات للابتوب و راح الحل مالي :crash:

بشوفه بكومبيوتري بالقسم اذا في نسخه :fk:


تمام .. بانتظر الحل

عالم الحاسوب
27 - 02 - 2009, 15:25
حليته مره ثانيه :icon_exclaim: << بس هنا ما عندي كومبايلر :crash:

بس اهم شي تكون الفكره واضحه


#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream fin("skyscraper.txt);
int prob = 0;
while(1){
double a;
int area;
int floors = 0;
fin >> a;
if(a == -1.0) break;
++prob;
area = (int) a;
while(area >= 1.0){
++floors;
area = area * 0.8;
}
cout << "Problem " << prob << ": " << floors << endl;
}

fin.close();
return 0;
}





بكره بسوي له كومبايل و بشوف لو فيه خطأ !! بس حسب التريسينج اللي سويتها المفروض الحل صحيح :ee:

Mazin
27 - 02 - 2009, 15:32
حليته مره ثانيه :icon_exclaim: << بس هنا ما عندي كومبايلر :crash:

بس اهم شي تكون الفكره واضحه


#include <iostream>
#include <fstream>

using namespace std;

int main()
{
"ifstream fin("skyscraper.txt);
int prob = 0;
while(1){
double a;
int area;
int floors = 0;
fin >> a;
if(a == -1.0) break;
++prob;
area = (int) a;
while(area >= 1.0){
++floors;
area = area * 0.8;
}
cout << "Problem " << prob << ": " << floors << endl;
}

fin.close();
return 0;
}





بكره بسوي له كومبايل و بشوف لو فيه خطأ !! بس حسب التريسينج اللي سويتها المفروض الحل صحيح :ee:



البرنامج يشتغل .. :ay:

عالم الحاسوب
27 - 02 - 2009, 15:36
البرنامج يشتغل .. :ay:

ما شاء الله علي << احسن عن الكومبايلر :lk:

هما الحلين بنفس الفكره تقريبا ..

بس ما حد غيرنا شارك في الحل :icon_wink:

admin
15 - 03 - 2009, 12:27
مــا شاء الله عليـــكم... اشتغلتوا عــدل في الموضوع ^_^

و بانتظار المزيـــد من أسئلـة الـ acm .... <<< هالأسئله فيها أفكار حلوه

..

حاليــــا ما عندي البرنامج في الجهاز :ev:

عالم الحاسوب
15 - 03 - 2009, 22:21
مــا شاء الله عليـــكم... اشتغلتوا عــدل في الموضوع ^_^

و بانتظار المزيـــد من أسئلـة الـ acm .... <<< هالأسئله فيها أفكار حلوه

..

حاليــــا ما عندي البرنامج في الجهاز :ev:

ان شاء الله قريبا :1eye:

حسين الغافري
15 - 03 - 2009, 22:28
في انتظار مسابقة البرمجة التي تنظمها مجموعتنا :1eye:

احتمال اكون من الحكام :1eye::gt:

عالم الحاسوب
15 - 03 - 2009, 22:31
في انتظار مسابقة البرمجة التي تنظمها مجموعتنا :1eye:

احتمال اكون من الحكام :1eye::gt:

ايه متحمسين لها :ms:

حكام !! انت زين تعرف تفتح C++ << انت بتنزل برامج اظن:ek: