2015 多校第四场

一定要补上  o(╯□╰)o。。

5327 签到。。

 1 /*Author :usedrose  */
 2 /*Created Time :2015/7/31 22:36:32*/
 3 /*File Name :2.cpp*/
 4 #include <cstdio>
 5 #include <iostream>
 6 #include <algorithm>
 7 #include <sstream>
 8 #include <cstdlib>
 9 #include <cstring>
10 #include <climits>
11 #include <vector>
12 #include <string>
13 #include <ctime>
14 #include <cmath>
15 #include <deque>
16 #include <queue>
17 #include <stack>
18 #include <set>
19 #include <map>
20 #define INF 0x3f3f3f3f
21 #define eps 1e-8
22 #define pi acos(-1.0)
23 #define MAXN 1110
24 #define OK cout << "ok" << endl;
25 #define o(a) cout << #a << " = " << a << endl
26 #define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
27 using namespace std;
28 typedef long long LL;
29 
30 bool is(int x)
31 {
32     int a[10];
33     memset(a, 0, sizeof(a));
34     while (x) {
35         int k = x%10;
36         if (a[k]) return false;
37         a[k]++;
38         x /= 10;
39     }
40     return true;
41 }
42 
43 int num[100010];
44 
45 void init()
46 {
47     for (int i = 1;i <= 100005; ++ i) {
48         num[i] = num[i-1] + is(i);
49     }
50 }
51 
52 int main()
53 {
54     //freopen("data.in","r",stdin);
55     //freopen("data.out","w",stdout);
56     cin.tie(0);
57     ios::sync_with_stdio(false);
58     init();
59     int T;
60     cin >> T;
61     while (T--) {
62         int l, r;
63         cin >> l >> r;
64         cout << num[r] - num[l-1] << endl;
65     }
66     return 0;
67 }
View Code

 

5328 再签一次。。

 1 #include <stdio.h>
 2 #include <algorithm>
 3 
 4 #define MAXN 1000005
 5 
 6 int a[MAXN];
 7 
 8 inline void solve()
 9 {
10     int n;
11     scanf("%d",&n);
12     int i;
13     for (i=1;i<=n;i++) {
14         scanf("%d",a+i);
15     }
16     int ans=std::min(2,n);
17     
18     int l=1;
19     for (i=3;i<=n;i++) {
20         bool f= 2*a[i-1]==a[i-2]+a[i];
21         if (!f) l=i-1;
22         ans=std::max(ans,i-l+1);
23     }
24     
25     l=1;
26     for (i=3;i<=n;i++) {
27         bool f= 1LL*a[i-1]*a[i-1]==1LL*a[i-2]*a[i];
28         if (!f) l=i-1;
29         ans=std::max(ans,i-l+1);
30     }
31     
32     printf("%d\n",ans);
33 }
34 
35 int main()
36 {
37     int T;
38     scanf("%d",&T);
39     int i;
40     for (i=1;i<=T;i++) {
41         solve();
42     }
43 }
View Code

 

hdu5335

主要是贪心..

 1 /*Author :usedrose  */
 2 /*Created Time :2015/8/1 9:29:16*/
 3 /*File Name :2.cpp*/
 4 #pragma comment(linker, "/STACK:1024000000,1024000000") 
 5 #include <cstdio>
 6 #include <iostream>
 7 #include <algorithm>
 8 #include <sstream>
 9 #include <cstdlib>
10 #include <cstring>
11 #include <climits>
12 #include <vector>
13 #include <string>
14 #include <ctime>
15 #include <cmath>
16 #include <deque>
17 #include <queue>
18 #include <stack>
19 #include <set>
20 #include <map>
21 #define INF 0x3f3f3f3f
22 #define eps 1e-8
23 #define pi acos(-1.0)
24 #define MAXN 1110
25 #define OK cout << "ok" << endl;
26 #define o(a) cout << #a << " = " << a << endl
27 #define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
28 using namespace std;
29 typedef long long LL;
30 
31 int T, n, m, tx[4] = {0, 0, 1, -1}, ty[4] = {1, -1, 0, 0};
32 char S[1100][1100];
33 bool used[1100][1100];
34 int xx[1100000], yy[1100000];
35 
36 void bfs()
37 {
38     memset(used, false, sizeof(used));
39     used[1][1] = true;
40     int q = 1, h = 1;
41     xx[q] = yy[q] = 1;
42     for (;q <= h; ++ q) 
43         if (S[xx[q]][yy[q]] == '0') {
44             for (int i = 0;i < 4; ++ i) {
45                 int X = xx[q] + tx[i];
46                 int Y = yy[q] + ty[i];
47                 if (X > 0 && X <= n && Y > 0 && Y <= m && !used[X][Y]) {
48                     h++;
49                     xx[h] = X;
50                     yy[h] = Y;
51                     used[X][Y] = true;
52                 }
53             }        
54         }
55         if (used[n][m] && S[n][m] == '0') {
56             puts("0");
57             return;
58         }
59     int ma = 0;
60     for (int i = 1;i <= n; ++ i)
61         for (int j = 1;j <= m; ++ j)
62             if (used[i][j])
63                 ma = max(ma, i + j);
64     printf("1");
65     for (int i = ma; i < n+m; ++ i) {
66         char mi = '1';
67         for (int j = 1;j <= n; ++ j) 
68             if (1 <= i - j && i-j <= m && used[j][i-j]) {
69                 mi = min(mi, S[j+1][i-j]);
70                 mi = min(mi, S[j][i-j+1]);
71             }
72         printf("%c", mi);
73         for (int j = 1;j <= n; ++ j)
74             if (1 <= i - j && i -j <= m && used[j][i-j]) {
75                 if (S[j+1][i-j] == mi) used[j+1][i-j] = true;
76                 if (S[j][i-j+1] == mi) used[j][i-j+1] = true;
77             }
78     }
79     puts("");
80 }
81 
82 int main()
83 {
84     scanf("%d", &T);
85     while (T--) {
86         scanf("%d%d", &n, &m);
87         for (int i = 1;i <= n; ++ i)
88             scanf("%s", S[i]+1);
89         for (int i = 0;i <= n+1; ++ i) 
90             S[i][0] = '2', S[i][m+1] = '2';
91         for (int i = 0;i <= m + 1; ++ i)
92             S[0][i] = '2', S[n+1][i] = '2';
93         bfs();
94     }
95     return 0;
96 }
View Code

 

posted @ 2015-07-31 19:27  UsedRose  阅读(112)  评论(0编辑  收藏  举报