这道题我一开始是这么写的,AC 了:
#include <bits/stdc++.h>
using namespace std;
double s1;
int s, ans;
int main() {
cin >> s1;
s = s1 * 100000000;
for(int p1 = 1; p1 <= 100; p1++)
for(int p2 = 1; p2 <= 100; p2++)
for(int p3 = 1; p3 <= 100; p3++)
for(int p4 = 1; p4 <= 100; p4++)
if(p1 * p2 * p3 * p4 == s) ans++;
cout << ans;
return 0;
}
然后我返回去的时候又读了一边题,才看见:
容易发现,S=(1−p1)⋅(1−p2)⋅(1−p3)⋅(1−p4)。
而我判断的是 if(p1 * p2 * p3 * p4 == s),也过了。这是为什么???