5 条题解

  • 2
    @ 2022-11-6 8:43:11
    #include <bits/stdc++.h>
    
    using namespace std;
    
    double a, b, r;
    int k;
    
    int main() {
    	scanf("%lf%lf", &a, &b);
    	k = a / b;
    	r = a - k * b;
    	printf("%lf", r);
    	return 0;
    }
    
  • 1
    @ 2023-10-1 15:19:14
    #include<iostream> 
    #include<cstdio>
    using namespace std;
    int main(){
    	double a,b,c,e;
    	int d;
    	scanf("%lf %lf",&a,&b);
    	c = a/b;
    	d = c;
    	e = a-b*d;
    	cout << e;
    	return 0;
    }
    
    • 0
      @ 2023-10-22 11:03:03
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          double a,b;
          cin>>a>>b;
          cout<<fmod(a,b)<<endl;
          return 0;
      }
      
      • 0
        @ 2022-7-12 12:04:49

        #include<bits/stdc++.h> using namespace std; int main() { int k; double a,b,c; cin>>a>>b; k=a/b; c=a-b*k; cout<<c; return 0; } //声明:此代码经过我本人测试,运行无误,注意语言选C++14哦(此行为注释,请勿复制)

        • -1
          @ 2022-4-16 19:25:31

          显然数据不够强,众所周知,2^1023也是双精度浮点数,2^-1074也是双精度浮点数,而两个任意的浮点数fmod都是良好定义不需要舍入的,于是你可以:

          #include <iostream>
          #include <cstdio>
          #include <cmath>
          int main() {
            double dmin=pow(2,-1074);
            double dsor=dmin*(2099);
            for(int i=-1074;i<1024;i++)
              printf("%5.5g%s",
                fmod(pow(2,i),dsor)/dmin,
                (i+1074+1)%8==0?"\n":" "
              );
            return 0;
          }
          

          然后先算a/b就会瞬间爆炸。

          所以只是需要测试数据里把2^1023、2^-1074(*p)十进制精确值的每一位数打印出来,这个输入数据才不会被杠(

          • 1

          信息

          ID
          6838
          时间
          1000ms
          内存
          128MiB
          难度
          1
          标签
          递交数
          82
          已通过
          39
          上传者