@lawk97
2017-04-03T21:11:42.000000Z
字数 2234
阅读 1151
训练赛
[LightOJ 1022]
A circle is placed perfectly into a square. The term perfectly placed
means that each side of the square is touched by the circle, but the
circle doesn't have any overlapping part with the square. See the
picture below.Now you are given the radius of the circle. You have to find the area
of the shaded region (blue part). Assume that pi = 2 * acos (0.0)
(acos means cos inverse).
Input
Input starts with an integer T (≤ 1000), denoting the number of test
cases.Each case contains a floating point number r (0 < r ≤ 1000) denoting
the radius of the circle. And you can assume that r contains at most
four digits after the decimal point.
Output
For each case, print the case number and the shaded area rounded to
two places after the decimal point.
Sample Input
3
20
30.091
87.0921
Sample Output
Case 1: 343.36
Case 2: 777.26
Case 3: 6511.05
Hint
This problem doesn't have special judge. So, be careful about
precision problems. Better to add a small value to your result to
avoid precision problems. For example, add 10-9 to your result.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
int main(){
int t;
scanf("%d",&t);
for(int i=1;i<=t;i++){
double f,s,pi;
pi=2.0*acos(0.0);
scanf("%lf",&f);
s=4*f*f-pi*f*f;
printf("Case %d: %.2f\n",i,s);
}
return 0;
}
[LightOJ - 1035]
Given an integer N, you have to prime factorize N! (factorial N).
Input
Input starts with an integer T (≤ 125), denoting the number of test
cases.Each case contains an integer N (2 ≤ N ≤ 100).
Output
For each case, print the case number and the factorization of the
factorial in the following format as given in samples.Case x: N = p1 (power of p1) * p2 (power of p2) * ...
Here x is the case number, p1, p2 ... are primes in ascending order.
Sample Input
3
2
3
6
Sample Output
Case 1: 2 = 2 (1)
Case 2: 3 = 2 (1) * 3 (1)
Case 3: 6 = 2 (4) * 3 (2) * 5 (1)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
int ha[105];
int main(){
int t,kase=0;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
for(int i=2;i<=100;i++){
ha[i]=0;
}
for(int i=2;i<=n;i++){
int te=i;
for(int j=2;j<=te;j++){
if (te%j==0)
{
te=te/j;
ha[j]++;
j--;
}
}
}
printf("Case %d: %d = ",++kase,n);
int flag=0;
for(int i=2;i<=n;i++){
if (ha[i]==0)
{
continue;
}
if (flag)
{
printf(" * ");
}
flag=1;
printf("%d (%d)",i,ha[i]);
}
printf("\n");
}
return 0;
}