Skip to content

Commit 64d5166

Browse files
committed
hhh
1 parent 28ee2fe commit 64d5166

File tree

8 files changed

+167
-33
lines changed

8 files changed

+167
-33
lines changed

KMP.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
Some code of codeforces.
2-
I am SBBBBBBBBB~~~~~😄
1+
Algorithm Code. I am SBBBBBBBBB~~~~~😄
2+
3+
###[codeforces](http://codeforces.com/)
4+
[做的几场codeforces的代码](https://github.com/openinx/algorithm-solution/tree/master/codeforces)
5+
6+
###[hunnu_201012_acm_monthly](https://github.com/openinx/algorithm-solution/tree/master/hunnu_201012_acm_monthly)
7+
8+
###[hunnu_3th_programming_contest](https://github.com/openinx/algorithm-solution/tree/master/hunnu_3th_programming_contest)
9+
10+
###[LeetCode Solution](https://oj.leetcode.com/)
11+
我的博客上有[leetcode151总结](http://openinx.github.io/2014/07/20/leetcode-151-finished/)
12+
13+
###[poj](https://github.com/openinx/algorithm-solution/tree/master/poj)
14+
[poj](http://poj.org)部分题解。
15+
16+
###[the-kth-number-code](https://github.com/openinx/algorithm-solution/tree/master/the-kth-number-code)
17+
写过一篇[从第K元素看数据结构](http://openinx.github.io/2014/03/02/the-k-the-number-in-algorithm/)的博客。 这里是博客涉及到的代码。
18+

codeforces/round257/a.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
#include <algorithm>
4+
#include <queue>
5+
6+
using namespace std;
7+
8+
9+
int main(){
10+
int n , m , i, val[101] , k;
11+
while( cin >> n >> m ){
12+
for(i = 1 ; i <= n ; ++ i)
13+
cin >> val[i];
14+
queue<int> q ;
15+
for(i = 1 ; i <= n; ++ i)
16+
q.push(i);
17+
while(!q.empty()){
18+
k = q.front(); q.pop();
19+
val[k] -= m;
20+
if(val[k] > 0 )
21+
q.push(k);
22+
}
23+
cout << k << endl;
24+
}
25+
return 0 ;
26+
}

codeforces/round257/a.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5 2
2+
1 3 1 4 2
3+
4+
5+
6 4
6+
1 1 2 2 3 3

codeforces/round257/b.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
#include <algorithm>
4+
5+
6+
using namespace std;
7+
8+
typedef long long lld;
9+
const lld mod = 1000000007;
10+
11+
lld t[2][2];
12+
13+
void mul(lld a[2][2], lld b[2][2]){
14+
lld i , j , k, sum = 0 ;
15+
for(i = 0 ; i < 2 ;++ i)
16+
for(j = 0 ; j < 2 ; ++ j){
17+
sum = 0 ;
18+
for(k = 0 ; k < 2 ; ++ k){
19+
sum = ( sum + a[i][k] * a[k][j]) % mod ;
20+
sum = ( sum + mod ) % mod;
21+
}
22+
t[i][j] = sum;
23+
}
24+
}
25+
26+
lld calc(lld n, lld f2, lld f1){
27+
int i , j;
28+
if(n == 1) return f1;
29+
if(n == 2) return f2;
30+
lld a[2][2] = {{1, -1},{1, 0}}, res[2][2] = {{1, 0}, {0, 1}}, ans ;
31+
n -- ;
32+
while(n){
33+
if(n & 1){
34+
mul(res, a);
35+
for(i = 0 ; i < 2 ; ++ i)
36+
for(j = 0 ; j < 2 ; ++ j)
37+
res[i][j] = t[i][j] ;
38+
}
39+
n >>= 1;
40+
mul(a, a);
41+
for(i = 0 ; i< 2; ++i)
42+
for(j = 0 ; j < 2 ; ++ j)
43+
a[i][j] = t[i][j];
44+
}
45+
ans = a[1][0] * f2 % mod + a[1][1] * f1 % mod;
46+
ans = (ans + mod ) % mod ;
47+
return ans;
48+
}
49+
50+
int main(){
51+
lld f1, f2, n ;
52+
while( cin >> f1 >> f2 >> n)
53+
cout << calc(n, f2, f1) << endl;
54+
return 0;
55+
}

codeforces/round257/b.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2 3
2+
3
3+
4+
5+
0 -1
6+
2
7+

codeforces/round257/b2.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
#include <cstdio>
4+
#include <string>
5+
6+
using namespace std;
7+
8+
9+
typedef long long lld;
10+
const lld mod = 1000000007;
11+
12+
13+
lld f(lld x){
14+
return (( x % mod + mod ) % mod + mod ) % mod;
15+
}
16+
17+
int main(){
18+
lld x , y , n;
19+
while( cin >> x >> y >> n){
20+
n = ( n - 1 ) % 6 + 1;
21+
if( n == 1) cout << f(x) << endl;
22+
if( n == 2) cout << f(y) << endl;
23+
if( n == 3) cout << f(y - x) << endl;
24+
if( n == 4) cout << f(-x) << endl;
25+
if( n == 5) cout << f(-y) << endl;
26+
if( n == 6) cout << f(x-y) << endl;
27+
}
28+
return 0 ;
29+
}

codeforces/round257/c.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
#include <algorithm>
4+
5+
using namespace std;
6+
7+
typedef long long lld;
8+
9+
int main(){
10+
lld n , m , k , ans;
11+
while( cin >> n >> m >> k ){
12+
if( k > n + m - 2) {
13+
cout << -1 << endl; continue;
14+
}
15+
lld ans = 0, x, start = max(k/2 - 100, (lld)0), end = min(k / 2 + 100, min(m - 1, k));
16+
for( x = start ; x <= end; ++ x){
17+
lld a = ( m % (x + 1) == 0 ? m / (x + 1): m % (x + 1));
18+
lld b = ( n % (k - x + 1) == 0 ? n / (k - x + 1): n % (k - x + 1));
19+
lld t = a * b;
20+
if(ans < t)
21+
ans = t;
22+
}
23+
cout << ans << endl;
24+
}
25+
return 0 ;
26+
}

0 commit comments

Comments
 (0)