HDOJ 2011~2020 水题2

个人感觉除了2018外都很水。直接发代码了:

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// HDOJ 2011 ~ 2020
// Author: Tanky Woo
#include <iostream>
#include <cmath>
using namespace std;
 
// HDOJ 2011
/*
int m[100];
int main()
{
	int n;
	double tot;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &m[i]);
	for(int i = 1; i <= n; ++i)
	{
		int flag = 1;
		tot = 0.0;
		for(int j = 1; j <= m[i]; ++j)
		{
			tot += flag*1.0/j;
			flag = -flag;
		}
		printf("%.2lf\n", tot);
	}
	return 0;
}
*/	
 
// HDOJ 2012
/*
 
bool IsPrime(int n)
{
	for(int i = 2; i*i <= n; ++i)
		if(n % i == 0)
			return 0;
	return 1;
}
 
int main()
{
	int x, y;
	while(scanf("%d %d", &x, &y) && (x || y))
	{
		int flag = 1;
		for(int i = x; i <= y; ++i)
			if(IsPrime(i*i+i+41) == 0)
			{
				flag = 0;
				break;
			}
		if(flag)
			printf("OK\n");
		else
			printf("Sorry\n");
 
	}
	return 0;
}
*/
 
// HDOJ 2013
// 找规律,每天吃掉的个数:
// 1 3 6 12 22  ...
// 相加就是总数
// 不过记的以前好像不是这个方法的。。。
/*
int main()
{
	int day, t, tot = 0;
	while(scanf("%d", &day) != EOF)
	{
		if(day == 1)
			printf("1\n");
		else
		{
			t = 3;
			tot = 3;
			for(int i = 1; i < day-1; ++i)
			{
				t *= 2;
				tot += t;
			}
			printf("%d\n", tot+1);
		}	
	}
	return 0;
}
*/
 
// HDOJ 2014
/*
int n;
int num[100];
int max_num, min_num, max_id, min_id;
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		double sum = 0.0;
		min_num = 101;
		max_num = -1;
		for(int i = 0; i < n; ++i)
		{
			scanf("%d", &num[i]);
			if(num[i] > max_num)
			{
				max_num = num[i];
				max_id = i;
			}
			if(num[i] < min_num)
			{
				min_num = num[i];
				min_id = i;
			}
		}
		for(int i = 0; i < n; ++i)
		{
			if(i == max_id || i == min_id)
				continue;
			sum += num[i];
		}
		printf("%.2lf\n", sum/(n-2));
	}
	return 0;
}
*/
 
// HDOJ 2015
/*
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m) != EOF)
	{
		int cnt = 0, tot = 0;
		for(int i = 0, num = 2; i < n; ++i, num += 2)
		{
			tot += num;
			cnt++;
			if(cnt == m && i != n-1)   //汗,在cnt == m同时 i == n-1时要多输出空格,结果就PE了
			{
				printf("%d ", tot/cnt);
				cnt = 0;
				tot = 0;
			}
			else if(i == n-1)
			{
				printf("%d", tot/cnt);
				cnt = 0;
				tot = 0;
			}
		}
		printf("\n");
	}
	return 0;
}
*/
 
 
// HDOJ 2016
/*
int num[101];
int min_num = 1000000, min_id;
int main()
{
	int n;
	while(scanf("%d", &n)!=EOF && n)
	{
		min_num = 10000000;
		min_id = 0;
		for(int i = 0; i < n; ++i)
		{
			scanf("%d", &num[i]);
			if(min_num > num[i])
			{
				min_num = num[i];
				min_id = i;
			}
		}
		int temp = num[0];
		num[0] = min_num;
		num[min_id] = temp;
		for(int i = 0; i < n; ++i)
			if(i == n-1)
				printf("%d\n", num[i]);
			else
				printf("%d ", num[i]);
		memset(num, 0, sizeof(num));
	}
	return 0;
}
*/
 
 
// HDOJ 2017
/*
int cnt;
char arr[1000];
int main()
{
	int n;
	scanf("%d", &n);
	while(n--)
	{
		//getchar();
		memset(arr, 0, sizeof(arr));
		cnt = 0;
		scanf("%s", arr);
		for(int i = 0; i < strlen(arr); ++i)
			if(arr[i] >= '0' && arr[i] <= '9')
				cnt++;
		printf("%d\n", cnt);
		cnt = 0;
	}
	return 0;
}
*/
 
 
// HDOJ 2018
// 递推!
/*
int f[100], g[100];
int main()
{
	f[1] = 1;
	f[2] = 2;
	f[3] = 3;
	f[4] = 4;
	f[5] = 6;
	g[2] = 1;
	g[3] = 1;
	g[4] = 1;
	g[5] = 2;
	for(int i = 6; i < 55; ++i)
	{
		g[i] = f[i-4] + g[i-3];
		f[i] = f[i-1] + g[i];
	}
	int year;
	while(scanf("%d", &year) && year)
	{
		printf("%d\n", f[year]);
	}
	return 0;
}
*/
 
 
// HDOJ 2019
/*
int n, m;
int num[100];
int main()
{
	while(scanf("%d %d", &n, &m) && (n || m))
	{
		int id = 0;
		for(int i = 0; i < n; ++i)
			scanf("%d", &num[i]);
		for(int i = 0; i < n; ++i)
			if(num[i] > m)
			{
				id = i;
				break;
			}
		for(int i = 0; i < id; ++i)
			printf("%d ", num[i]);
		printf("%d ", m);
		for(int i = id; i < n; ++i)
			if(i == n-1)
				printf("%d\n", num[i]);
			else
				printf("%d ", num[i]);
 
	}
	return 0;
}
*/
 
// HDOJ 2020
/*
int num[101];
int n, temp;
int main()
{
	while(scanf("%d", &n) && n)
	{
		for(int i = 0; i < n; ++i)
			scanf("%d", &num[i]);
		for(int i = 0 ; i < n; ++i)
			for(int j = i+1; j < n; ++j)
				if(abs(num[i]) < abs(num[j]))
				{
					temp = num[i];
					num[i] = num[j];
					num[j] = temp;
				}
		for(int i = 0; i < n; ++i)
			if(i == n-1)
				printf("%d\n", num[i]);
			else
				printf("%d ", num[i]);
	}
	return 0;
}
*/

发布者

Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

发表评论

电子邮件地址不会被公开。 必填项已用*标注