FJ_00460 @ 2023-05-13 18:30:31
我WA了,附赠代码!大佬救命!!!
#include<bits/stdc++.h>
using namespace std;
int n;
double pi = 3.141593;
void Main(int a){
if(a == 1)cout << "I love Luogu!";
if(a == 2)cout << "6" << " " << "4" <<"\n";
if(a == 3)cout << "3" << "\n" << "12" << "\n" << "2";
if(a == 4){
printf(".3lf", 1.0 * 500 / 3);
}
if(a == 5)cout<<(220 + 260)/(20 + 12);
if(a == 6)cout<< sqrt(6 * 6 + 9 * 9);
if(a == 7)cout << "110" << "\n" << "90" << "\n" << "0";
if(a == 8)cout<<pi * 10<< "\n" <<pi * 25<< "\n" << 4 / 3 * pi * 125 << "\n" ;
if(a == 9)cout<< ((((1 + 1) * 2) + 1 * 2) + 1) * 2;
if(a == 10)cout << "9" << "\n";
if(a == 11)cout<< 1.0 * 100 / 3;
if(a == 12)cout << "13" << "\n" << "R" << "\n";
if(a == 13)cout<<(int)(pow(4 / 3 * pi * (4 * 4 * 4 + 10 * 10 * 10), 1.0 * 1 / 3));
if(a == 14)cout << "50" << "\n";
}
int main(){
cin >> n;
Main(n);
return 0;
}
by yeqiwei @ 2023-05-13 18:35:24
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int t;
const double pi=3.141593;
cin>>t;
switch(t)
{
case 1:cout<<"I love Luogu!";break;
case 2:cout<<"6 4";break;
case 3:cout<<"3\n12\n2";break;
case 4:printf("%0.3f",1.0*500/3);break;
case 5:cout<<"15";break;
case 6:cout<<sqrt(117);break;
case 7:cout<<"110\n90\n0";break;
case 8:cout<<10*pi<<"\n"<<pi*25<<"\n"<<4.0/3*pi*125;break;
case 9:cout<<"22";break;
case 10:cout<<"9";break;
case 11:cout<<(double)(100.0/3);break;
case 12:cout<<"13\nR";break;
case 13:cout<<(int)(pow(4.0/3*pi*1064,1.0/3));break;
case 14:cout<<"50";break;
}
return 0;
}
if(a == 8)cout<<pi * 10<< "\n" <<pi * 25<< "\n" << 4 / 3 * pi * 125 << "\n" ;
改成
if(a == 8)cout<<pi * 10<< "\n" <<pi * 25<< "\n" << 4 .0/ 3 * pi * 125 << "\n" ;
@water8424
by yeqiwei @ 2023-05-13 18:35:54
求关注
by Ryan_Yu @ 2023-05-13 18:37:58
把结果算出来不行吗?int
转 double
或者 double
转 int
会丢精度
by FJ_00460 @ 2023-05-13 18:38:35
@yeqiwei 79分?????
by yeqiwei @ 2023-05-13 18:59:57
我这儿AC了呀\ this
by yeqiwei @ 2023-05-13 19:11:43
你把你的测试点详情发给我
by yeqiwei @ 2023-05-13 19:13:36
我这儿是72分
by yeqiwei @ 2023-05-13 19:18:27
首先,第一个问题:
if(a == 4){
printf(".3lf", 1.0 * 500 / 3);
}
.3lf 前面的 % 呢?\ 改成这样:
if(a == 4){
printf("%.3lf", 1.0 * 500 / 3);
}
@water8424
by yeqiwei @ 2023-05-13 19:24:19
第二个问题:注意如果做整数除法时要输出小数,一定要把除数和被除数的其一后面加个.0,所以改成这样:
if(a == 8)cout<<pi * 10<< "\n" <<pi * 25<< "\n" << 4.0/ 3 * pi * 125 << "\n" ;
by yeqiwei @ 2023-05-13 19:27:43
第三个:括号呢?
if(a == 9)cout<< (((((1 + 1) * 2) + 1) * 2) + 1) * 2;