这场不说了,配合重大失误。。。
1002
计算分数和,有坑。。。看了Clarification才知道。
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 | /************************************************************************* > File Name: 1002.cpp > Author: skt > Mail: sktsxy@gmail.com > Created Time: 2014年08月21日 星期四 13时51分16秒 ************************************************************************/ #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <bitset> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <memory.h> #include <cassert> using namespace std; #define LL long long #define pb push_back #define mp make_pair #define eps 1e-8 #define MAXN 100005 template <typename T> inline T Max(T a, T b) {return a>b?a:b;} template <typename T> inline T Min(T a, T b) {return a<b?a:b;} template <typename T> inline T Abs(T a) {return a>0?a:-a;} int T, N, Cas = 1, a[MAXN]; void work() { printf("Case #%d: ", Cas ++); scanf("%d", &N); a[0] = 0; for (int i = 1; i <= N; i ++) { scanf("%d", &a[i]); } int cnt = 0; for (int i = 1; i <= N; i ++) { if (a[i] == 2 && a[i-1] == 1) { cnt ++; } if (a[i] == 1 && a[i-1] == 2) { cnt ++; } if (Abs(a[i] - a[i-1]) > 3) { printf("0\n"); return ; } if (a[i] == a[i-1] && a[i] != 1) { printf("0\n"); return ; } } if (a[N] == 0) { printf("%d\n", cnt + 1); } else { printf("%d\n", 2 * (cnt + 1)); } } int main() { scanf("%d", &T); while (T --) { work(); } return 0; } |
1004
水题
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 | /************************************************************************* > File Name: 1004.cpp > Author: skt > Mail: sktsxy@gmail.com > Created Time: 2014年08月21日 星期四 12时03分34秒 ************************************************************************/ #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <bitset> #include <algorithm> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <memory.h> #include <cassert> using namespace std; #define LL long long #define pb push_back #define mp make_pair #define eps 1e-8 #define MAXN 100005 template <typename T> inline T Max(T a, T b) {return a>b?a:b;} template <typename T> inline T Min(T a, T b) {return a<b?a:b;} int T, N, a[MAXN], Cas = 1; LL ans; void work() { printf("Case #%d: ", Cas ++); scanf("%d", &N); for (int i = 1; i <= N; i ++) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + N); ans = 0; LL tmp = 0; for (int i = 1; i <= N; i ++) { tmp += a[i]; } tmp -= a[N]; if (tmp > a[N]) { tmp += a[N]; ans = tmp / 2; if (tmp % 2) ans ++; } else { ans = a[N]; } cout << ans << endl; } int main() { scanf("%d", &T); while (T --) { work(); } return 0; } |