[Bestcoder] Valentine's Day Round 1001 - Ferries Wheel | HDU 5174
2015-02-14 21:32
459 查看
本题比赛时被hack的人好多 - -。
注意坑点:
3
2147483645 2147483646 2147483644
Answer : 1
注意坑点:
3
2147483645 2147483646 2147483644
Answer : 1
#include <stdio.h> #include <string.h> #include <map> #include <algorithm> #define INT_MAX 2147483647 using namespace std; int main() { int n, k = 1; long long ans; long long a[1000]; while(~scanf("%d", &n)) { ans = 0; map<int, int> mm; int cnt = 0, tmp; for(int i = 0; i < n; i++) { scanf("%d", &tmp); if(!mm[tmp]) { a[cnt++] = tmp; } mm[tmp]++; } if(cnt == 1) { printf("Case #%d: -1\n", k++); continue; } sort(a, a+cnt); for(int i = 0 ; i < cnt; i++) { if((a[(i - 1 + cnt) % cnt] + a[(i - 2 + cnt) % cnt]) % INT_MAX == a[i]) { ans += mm[a[(i - 1 + cnt) % cnt]]; } } printf("Case #%d: %d\n", k++, ans); } return 0; }
相关文章推荐
- BestCoder #Valentine's Day Round 1001 || hdu 5174
- BestCoder #Valentine's Day Round 1002 || hdu 5175
- HDU 5175 Misaki's Kiss again(数学 最大公约数 异或运算)——BestCoder Valentine's Day Round
- HDU 5147 Ferries Wheel(暴力 数组)——BestCoder Valentine's Day Round
- HDU 5104 Primes Problem(拆分素数和问题)【BestCoder Round #18 1001】
- BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611
- hdu 4956 Poor Hanamichi(bestcoder Round 6 1001)
- BestCoder Round #78 1001/ hdu 5655 CA Loves Stick
- [BestCoder] Round #25 1001 - Harry and Magical Computer | HDU 5154
- hdu 4883 bestcoder round 2 1001 TIANKENG’s restaurant
- BestCoder(Valentine's Day Round C题) hdu5176 The Experience of Love
- HDU5104 Primes Problem && BestCoder Round #18 1001
- hdu 4859 海岸线 Bestcoder Round 1
- BestCoder5 1001 Poor Hanamichi(hdu 4956) 解题报告
- BestCoder Round #81 (div.2):1001 Machine
- hdu 4990 Reading comprehension 矩阵快速幂or数论 bestcoder round 8b
- BestCoder Round #70 1001 Jam's math problem
- hdu 5269 ZYB loves Xor I && BestCoder Round #44
- BestCoder Round #33——1001——zhx's submissions
- BestCoder3 1001 Task schedule(hdu 4907) 解题报告