C.
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; #define LL long long #define N 1000 + 10 double a[N]; int n; int main() { while(~scanf("%d", &n)) { double sum = 0; for(int i = 0; i < n; i++) { scanf("%lf", a + i); sum += a[i]; } double v = sum / n; int ans = 0; for(int i = 0; i < n; i++) if(a[i] > v) ans++; printf("%d\n", ans); } return 0; }
#include <cstdio> #include <cmath> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define N 10000 + 10 #define eps 1e-9 int n; int b[N], c[N]; struct Node { int id; double v; } node[N]; int cmp(Node t1, Node t2) { return t1.v < t2.v; } int sgn(double x) { if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } int main() { while(~scanf("%d", &n)) { double t; int cnt = 0, cn1 = 0, cn2 = 0; double ans = 0; int flag = 0; double Max = -1e10; int index; for(int i = 1; i <= n; i++) { scanf("%lf", &t); if(t > Max) { Max = t; index = i; } if(t < 0) { node[++cnt].id = i; node[cnt].v = t; } if(t > 1) b[++cn1] = i; if(t == 1) flag = i; } if(n == 1) { printf("1\n1\n"); } else { sort(node + 1, node + 1 + cnt, cmp); int i; for(i = 1; i <= cnt; i++) if(node[i].v < -1) { c[++cn2] = node[i].id; } else break; if(i <= cnt) { if(cn2 & 1) { double tmp = node[i].v * node[i - 1].v; if(sgn(tmp - 1) > 0) { c[++cn2] = node[i].id; } else cn2--; } } if(i == cnt + 1 && (cn2 & 1)) cn2--; for(int i = 1; i <= cn1; i++) c[++cn2] = b[i]; if(cn2 == 0) { if(flag) { cn2 = 1; c[1] = flag; } else if(cnt >= 2) { cn2 = 2; c[1] = node[1].id; c[2] = node[2].id; if(sgn(node[1].v * node[2].v - Max) <= 0) { cn2 = 1; c[1] = index; } } else if(sgn(Max) >= 0) { cn2 = 1; c[1] = index; } } sort(c + 1, c + 1 + cn2); printf("%d\n", cn2); for(int i = 1; i <= cn2; i++) i == cn2 ? printf("%d\n", c[i]) : printf("%d ", c[i]); } } return 0; }
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> using namespace std; typedef long long LL; LL gao( double n, double m, double a, double b, double x, double y ) { LL s1, s2; s1 = s2 = 0; if( y ) s1 = ceil( n / ( ( int )( floor( b / y ) ) * a ) ); if( x ) s2 = ceil( ( m - y ) / ( ( int )( floor( a / x ) ) * b ) ); return s1 + s2; } int main() { int n, m, a, b, x, y; scanf( "%d%d%d%d", &n, &m, &a, &b ); LL ans = ( n / a ) * ( m / b ); x = n - n / a * a; y = m - m / b * b; LL s1 = gao( n, m, a, b, x, y ); LL s2 = gao( m, n, b, a, y, x ); ans += min( s1, s2 ); printf( "%I64d\n", ans ); return 0; }