歼灭弱题12
ZOJ 1813 弱
#include <iostream>
#include <iomanip>
using namespace std;
double PI = 3.1415927;
int main()
{
double d,t,l,s;
int r,xx=1;
while(cin >> d >> r >> t)
{
if(r==0) break;
l = d*PI*r/(5280*12);
s = l*3600/t;
cout << setiosflags(ios::fixed) << setprecision(2) << "Trip #" << xx++ << ": " << l << " " << s << endl;
}
return 0;
}
ZOJ 1402 弱
#include <iostream>
using namespace std;
int main()
{
int * p;
int n,i,a,b,fa,fb;
while(cin >> n)
{
if(n==0) break;
p = new int[n];
i = 0;a = b = 0;
while(n--)
{
cin >> p[i];
++i;
}
a = p[0];b = p[i-1];fa = 0;fb = i-1;
while(fa+1<=fb-1)
{
if(a==b)
{
a+=p[++fa];
b+=p[--fb];
}
else if(a>b)
{
b+=p[--fb];
}
else
{
a+=p[++fa];
}
}
if(a==b) cout << "Sam stops at position " << fa+1 << " and Ella stops at position " << fb+1 <<"." << endl;
else cout << "No equal partitioning." << endl;
delete[] p;
}
return 0;
}
ZOJ 1970 相当弱的一个题
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a,b;
int la,lb,i,j,t;
bool f1,f2;
while(cin >> a >> b)
{
f1=true;
t = -1;
for(i=0;i<a.size();++i)
{
f2=false;
for(j=t+1;j<b.size();++j)
{
if(a[i]==b[j])
{
f2=true;
t = j;
break;
}
}
if(f2==false)
{
f1=false;
break;
}
}
if(f1==false)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
return 0;
}
ZOJ 1904
好短的代码,嘿嘿
不过途中犯了个弱智问题,因为要开3次根号,却在math.h中找不到具体函数,查了半天明白:
原来 pow(double,double)是可以求的,唉,失败
#include <stdio.h>
#include <math.h>
int main()
{
int N,V;
while(scanf("%d %d",&N,&V))
{
if(N==0&&V==0) break;
printf("%.3f\n",pow(N*N*N - (6*V)/acos(-1.0),1.0/3));
}
}
浙公网安备 33010602011771号