sgu 144:meeting
純數學題,算概率
第一個人到達的時間做x軸,第二個人的到達時間做y軸
符合條件的概率是|x-y| <= z
如圖所示,正方形和兩條直線相交之間的陰影部分面積即是所求。

顯然的,如果兩個人的到達區間不相等,也只要求出矩形和直線相交的面積即可
1 /*
2 * SOUR:sgu144
3 * ALGO:概率
4 * DATE: 2009年 12月 13日 星期日 22:14:36 CST
5 * COMM:3 http://www.shnenglu.com/schindlerlee/
6 * 橫坐標代表第一個人到達的時間,縱坐標代表第二個人到達的時間
7 * |x-y| <= z
8 * */
9 #include<iostream>
10 #include<cstdio>
11 #include<cstdlib>
12 #include<cstring>
13 #include<algorithm>
14 using namespace std;
15 typedef long long LL;
16 const int maxint = 0x7fffffff;
17 const long long max64 = 0x7fffffffffffffffll;
18
19 double sqr(double x) { return x * x;}
20 int main()
21 {
22 double x,y,z,ans;
23 scanf("%lf%lf%lf",&x,&y,&z);
24 x *= 60,y *= 60;
25 ans = 1 - sqr(y-x-z)/sqr(y - x);
26 printf("%.7f\n",ans);
27 return 0;
28 }
29
30
sgu:169 numbers 純數學方法
不知道別人是怎么做的,我是純的打表,找規律。
發現只有11111111....1x的形式才可以,于是就再打個表看看。
11 % = 0
12 % = 0
13 % = 1
14 % = 2
15 % = 0
16 % = 4
17 % = 3
18 % = 2
19 % = 1
111 % = 0
112 % = 0
113 % = 2
114 % = 2
115 % = 0
116 % = 2
117 % = 5
118 % = 6
119 % = 2
1111 % = 0
1112 % = 0
1113 % = 0
1114 % = 2
1115 % = 0
1116 % = 0
1117 % = 4
1118 % = 6
1119 % = 3
11111 % = 0
11112 % = 0
11113 % = 1
11114 % = 2
11115 % = 0
11116 % = 4
11117 % = 1
11118 % = 6
11119 % = 4
111111 % = 0
111112 % = 0
111113 % = 2
111114 % = 2
111115 % = 0
111116 % = 2
111117 % = 6
111118 % = 6
111119 % = 5
1111111 % = 0
1111112 % = 0
1111113 % = 0
1111114 % = 2
1111115 % = 0
1111116 % = 0
1111117 % = 0
1111118 % = 6
1111119 % = 6
11111111 % = 0
11111112 % = 0
11111113 % = 1
11111114 % = 2
11111115 % = 0
11111116 % = 4
11111117 % = 3
11111118 % = 6
11111119 % = 7
111111111 % = 0
111111112 % = 0
111111113 % = 2
111111114 % = 2
111111115 % = 0
111111116 % = 2
111111117 % = 5
111111118 % = 6
111111119 % = 8
1111111111 % = 0
1111111112 % = 0
1111111113 % = 0
1111111114 % = 2
1111111115 % = 0
1111111116 % = 0
1111111117 % = 4
1111111118 % = 6
1111111119 % = 0
1 /*
2 * SOUR:sgu169
3 * ALGO:math
4 * DATE: 2009年 11月 29日 星期日 11:11:37 CST http://www.shnenglu.com/schindlerlee
5 * COMM:2
6 * */
7 #include<iostream>
8 #include<cstdio>
9 #include<cstdlib>
10 #include<cstring>
11 #include<algorithm>
12 using namespace std;
13 typedef long long LL;
14 const int maxint = 0x7fffffff;
15 const long long max64 = 0x7fffffffffffffffll;
16
17 int n;
18 int main()
19 {
20 int i,j,pre = 1;
21 scanf("%d",&n);
22 if(n == 1) {
23 printf("8\n");
24 }else {
25 int res = 1;
26 if((n-1) % 3 == 0) res +=2;
27 if((n-1) % 6 == 0) res ++;
28 printf("%d\n",res);
29 }
30
31 return 0;
32 }
33