Re: [ACM ] 107 code已更新
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[]) {
int a = 0, b = 0, n = 0;
cin >> a >> b;
for (int i = 2;i <= a;i++) { //找n
float c = logf((float)a) / logf((float)b);
float d = logf((float)i) / logf((float)i - 1);
if (c == d) {
n = i;
break;
}
} // 找k
int k = (int)(logf((float)a) / logf((float)n));
int num = 1, length = a, sum = a, idle = 1;
for (int i = 0;i < k;i++) { //變魔術
num *= (n - 1); //變魔術的貓數
length /= n; //貓的身高
sum += (num * length); //總身高
idle += num; //總貓數
}
cout << idle - num << " " << sum << endl;
system("pause");
return 0;
}
※ 編輯: chrisdar 來自: 163.23.17.131 (07/10 15:20)
推
07/10 16:00, , 1F
07/10 16:00, 1F
→
07/10 16:03, , 2F
07/10 16:03, 2F
推
07/10 20:16, , 3F
07/10 20:16, 3F
→
07/10 20:20, , 4F
07/10 20:20, 4F
→
07/10 20:24, , 5F
07/10 20:24, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章