-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharpter5(2).txt
82 lines (80 loc) · 1.57 KB
/
charpter5(2).txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
A.斐波那契数列
/*
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std ;
long long map[10000010] ;
int main()
{
long long ans = 2 ;
int n ; cin >> n ;
if( n == 1 || n == 2 ) { cout << 1 << endl ; return 0 ; }
map[1] = 1 ; map[2] = 1 ;
for( int i = 3 ; i<= n ; i++ )
{ map[i] = map[i-1] + map[i-2] ; }
cout << map[n] << endl ;
return 0 ;
}
*/
B.计算排列
/*
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std ;
int main()
{
int m , n ;
cin >> n >> m ;
long long ans = 1 ;
for( long long i = n- m + 1 ; i<= n ;i ++)
ans *= i ;
cout << ans << endl ;
return 0 ;
}
*/
C.分糖果
/*
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std ;
int map[20] ;
bool check(int n) {return n % 2== 0 ? true : false ; }
bool check_all()
{
int a = map[1] ;
for( int i = 2 ; i<= 10 ; i++ ) if(map[i] != a)
return false ;
return true ;
}
void change()
{
int map1[20] = {0} ;
map1[11] = map[1] / 2 ;
for( int i = 10 ; i >= 1 ; i-- )
{
map1[i] = map[i] /2 ; map[i]/=2 ;
map[i] += map1[i+1] ;
}
}
int main()
{
//freopen("a.txt" , "r" , stdin ) ;
for( int i = 1 ; i<= 10 ; i ++) cin >> map[i] ;
int t = 0 ;
while(!check_all())
{
change() ;
for( int i = 1 ; i <= 10 ; i++ )
if(!check(map[i])) map[i] ++ ;
t ++ ;
}
cout << t << " " << map[1] << endl ;
return 0 ;
}
*/