[luoguP1097] 統計數字(水)
阿新 • • 發佈:2017-06-28
ostream nbsp org urn tchar return blog print main
傳送門
這麽水的題,也只有提高組第一題了吧
代碼
#include <cstdio> #include <iostream> #include <algorithm> #define N 200001 int n, cnt = 1; int a[N]; inline int read() { int x = 0, f = 1; char ch = getchar(); for(; !isdigit(ch); ch = getchar()) if(ch == ‘-‘) f = -1; for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - ‘0‘; return x * f; } int main() { int i; n = read(); for(i = 1; i <= n; i++) a[i] = read(); std::sort(a + 1, a + n + 1); for(i = 1; i <= n; i++) { if(a[i] ^ a[i + 1]) { printf("%d %d\n", a[i], cnt); cnt = 1; } else cnt++; } return 0; }
[luoguP1097] 統計數字(水)