为什么这程序在POJ会Output limit Exceeded

tjyjx7946358 2010-07-19 09:42:40
在POJ上做了一题,I Think I Need a Houseboat,http://acm.pku.edu.cn/JudgeOnline/problem?id=1005


代码如下:

#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
const double pi=3.1415926;

int main(){
int n;
ifstream in("abc.txt");
in>>n;
double a,b;
for(int i=0;i<n;++i){
in>>a>>b;
double s=0;
int j;
j=(int)floor(pi*(a*a+b*b)/100);
cout<<"Property "<<i+1<<": This property will begin eroding in year "
<<j+1<<"."<<endl;
}
cout<<"END OF OUTPUT."<<endl;
return 0;
}


...全文
221 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tjyjx7946358 2010-07-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dotcpp 的回复:]
C/C++ code

#include<iostream>
#include<cmath>
using namespace std;
const double pi=3.1415926;

int main(){
int n;
cin>>n;
double a,b;
for(int i=0;i<n;++i){
cin>>a>……
[/Quote]
后面我也是用cin读入不用文件读入通过了。。
DotCpp 2010-07-19
  • 打赏
  • 举报
回复

#include<iostream>
#include<cmath>
using namespace std;
const double pi=3.1415926;

int main(){
int n;
cin>>n;
double a,b;
for(int i=0;i<n;++i){
cin>>a>>b;
double s= pi*(a*a+b*b);
int j=s/100;
cout<<"Property "<<i+1<<": This property will begin eroding in year "
<<j+1<<"."<<endl;
}
cout<<"END OF OUTPUT."<<endl;
system("pause");
return 0;
}


提交时用C++,别用G++

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧