【ACM打卡】ZOJ 1037 1049
1037
简单题,看着图形吓蠢了,然后看了下解析,自己画图找规律。n*m个点组成的矩形路线,不重复走回路,输出长长度。找规律:都不为偶数时,m*n+0.41;其他,m*n。
昨天弄了超级久,因为没发现格式要求 a blank line,笑嘻嘻了。
1049 给出n组点,看几年后半圆每年50扩展 覆盖上给定点。比较:(x*x+y*y)*PI/2与50*i。
错误原因:序号除了问题,又笑嘻嘻了。
1037
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int m,n,a,i;
double s;
cin>>a;
for(i=0;i<a;i++){
cin>>m>>n;
cout<<"Scenario #"<<i+1<<":"<<endl;
cout <<fixed<<setprecision(2);
if((m%2)==0||(n%2)==0) s=(double)m*n;
else s=(double)m*n+0.41;
cout<<s<<endl<<endl;
}
return 0;
}
1049
#include<iostream>
#include<stdio.h>
using namespace std;
#define PI 3.1415927
int main(){
double S,s,x,y;
int T,i=1,t=0;
cin>>T;
while(t<T){
cin>>x>>y;
s=(x*x+y*y)*PI/2;
while(50*i<s){
i++;
}
t++;
printf("Property %d: This property will begin eroding in year %d.\n",t,i);
}
cout<<"END OF OUTPUT."<<endl;
}