Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么这个题也出现C++AC G++WA的囧事?#include <cstdio> #include <cmath> using namespace std; const int d[][2] = {{0, 0}, {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; long long ans; int main() { int t; char ch; scanf("%d", &t); for (int i = 0, x, y; i < t; ++i) { ans = x = y = 0; for (scanf("%c", &ch); ch != '5'; scanf("%c", &ch)) { if (ch < '1' || ch > '9') continue; int _x = x, _y = y; ans += (x += d[ch - '0'][0]) * _y - _x * (y += d[ch - '0'][1]); } if (ans < 0) ans = -ans; if (ans % 2 == 0) printf("%lld\n", ans / 2); else printf("%lld.5\n", ans / 2); } return 0; } rt,这个代码有问题么? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator