[关闭]
@lawk97 2017-04-03T21:11:42.000000Z 字数 2234 阅读 1151

集训队训练赛--20170402

训练赛


地址

A - Circle in Square

[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.

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. int main(){
  7. int t;
  8. scanf("%d",&t);
  9. for(int i=1;i<=t;i++){
  10. double f,s,pi;
  11. pi=2.0*acos(0.0);
  12. scanf("%lf",&f);
  13. s=4*f*f-pi*f*f;
  14. printf("Case %d: %.2f\n",i,s);
  15. }
  16. return 0;
  17. }

J - Intelligent Factorial Factorization

[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)

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <map>
  7. using namespace std;
  8. int ha[105];
  9. int main(){
  10. int t,kase=0;
  11. scanf("%d",&t);
  12. while(t--){
  13. int n;
  14. scanf("%d",&n);
  15. for(int i=2;i<=100;i++){
  16. ha[i]=0;
  17. }
  18. for(int i=2;i<=n;i++){
  19. int te=i;
  20. for(int j=2;j<=te;j++){
  21. if (te%j==0)
  22. {
  23. te=te/j;
  24. ha[j]++;
  25. j--;
  26. }
  27. }
  28. }
  29. printf("Case %d: %d = ",++kase,n);
  30. int flag=0;
  31. for(int i=2;i<=n;i++){
  32. if (ha[i]==0)
  33. {
  34. continue;
  35. }
  36. if (flag)
  37. {
  38. printf(" * ");
  39. }
  40. flag=1;
  41. printf("%d (%d)",i,ha[i]);
  42. }
  43. printf("\n");
  44. }
  45. return 0;
  46. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注