RT
为何有时候两个相等的值程序判断不相等,如:
#include<bits/stdc++.h>
using namespace std;
const int N=10;
long double a;
int cnt=1,ans[N+10];
bool zs[N+10];
inline int rd(){
int x=0,f=1;char s=getchar();
while(s<'0'||s>'9'){
if(s=='-')f=-1;
s=getchar();
}
while(s>='0'&&s<='9'){
x=x*10+s-'0';
s=getchar();
}
return x*f;
}
inline void shai(){
zs[1]=1;
for(int i=2;i<=N;i++){
if(!zs[i]){
ans[++cnt]=i;
}
for(int j=2;j<=cnt;j++){
if(i*ans[j]>N)break;
zs[ans[j]*i]=1;
if(i%ans[j]==0){
break;
}
}
}
ans[1]=1;
}
int main(){
cin>>a;
printf("%.19Lf\n",a);
long double o=0.3333333333333333333;
if(o==a){
cout<<"fk"<<endl;
}
// cout<<a<<endl;
shai();
for(int i=1;i<=cnt;i++){
cout<<ans[i]<<endl;
}
for(int i=1;i<=cnt;i++){
for(int j=i+1;j<=cnt;j++){
long double l=ans[i];
l/=ans[j];
cout<<ans[i]<<" "<<ans[j]<<" ";
printf("%.19Lf\n",l);
// cout<<l<<endl;
if(l==a){
cout<<ans[i]<<" "<<ans[j]<<endl;
return 0;
}
}
}
return 0;
}
输入样例为:
0.3333333333333333333