回答編集履歴
2
コード修正
test
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
```c
|
4
4
|
#include <stdio.h>
|
5
|
-
#include <math.h>
|
6
5
|
|
7
6
|
#define N 4
|
8
7
|
|
9
8
|
int longestSequenceOf1(long v) {
|
10
9
|
int max = 0;
|
11
|
-
for(int c=0; v>0; v>>=1) if(v&1)
|
10
|
+
for(int c=0; v>0; v>>=1) if(v&1) max=max<++c?c:max; else c=0;
|
12
11
|
return max;
|
13
12
|
}
|
14
13
|
void research(long *a, long vmax) {
|
@@ -18,11 +17,11 @@
|
|
18
17
|
}
|
19
18
|
}
|
20
19
|
int main(void){
|
21
|
-
long vmax =
|
20
|
+
long vmax = 1 << N;
|
22
21
|
long a[N+1] = {0};
|
23
22
|
research(a, vmax);
|
24
23
|
printf("m, m回以上連続で表となる確率\n");
|
25
|
-
for(int i=0; i<=N; i++) printf("%d, %.1f%%(%ld)\n", i,
|
24
|
+
for(int i=0; i<=N; i++) printf("%d, %.1f%%(%ld)\n", i, 100.0*a[i]/vmax, a[i]);
|
26
25
|
}
|
27
26
|
```
|
28
27
|
```plain
|
1
ついコードマークダウンに java と書いてしまった
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ありそうなビット扱い。 N は longビット数まで。
|
2
2
|
|
3
|
-
```
|
3
|
+
```c
|
4
4
|
#include <stdio.h>
|
5
5
|
#include <math.h>
|
6
6
|
|