题目传送:BestCoder Round #50 (div.2)
BC感觉越做越无语了
1001、Distribution money
AC代码:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;
int a[10005];
int main() {
int n;
while(scanf("%d", &n) != EOF) {
memset(a, 0, sizeof(a));
for(int i = 0; i < n; i ++) {
int t;
scanf("%d", &t);
a[t] ++;
}
int ans = -1;
for(int i = 0; i < 10005; i ++) {
if(a[i] > n - a[i]) {
ans = i;
}
}
if(ans != -1)printf("%d\n", ans);
else printf("-1\n");
}
return 0;
}
1002、Run
AC代码:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;
struct node {
int x, y;
}a[55];
int n;
int fun(node a, node b) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int main() {
while(scanf("%d", &n) != EOF) {
for(int i = 0; i < n; i ++) {
scanf("%d %d", &a[i].x, &a[i].y);
}
int ans = 0;
for(int i = 0; i < n; i ++) {
for(int j = i + 1; j < n; j ++) {
for(int k = j + 1; k < n; k ++) {
for(int l = k + 1; l < n; l ++) {
int x[6];
x[0] = fun(a[i], a[j]);
x[1] = fun(a[j], a[k]);
x[2] = fun(a[k], a[l]);
x[3] = fun(a[l], a[i]);
x[4] = fun(a[i], a[k]);
x[5] = fun(a[j], a[l]);
sort(x, x + 6);
if((x[0] == x[1]) && (x[0] == x[2]) && (x[0] == x[3]) && (x[4] == x[5])) {
ans ++;
}
}
}
}
}
printf("%d\n", ans);
}
return 0;
}
1003、The mook jong
AC代码:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;
LL dp[105];
int n;
int main() {
dp[1] = 1;
dp[2] = 2;
dp[3] = 3;
for(int i = 4; i < 65; i ++) {
dp[i] = dp[i - 1] + dp[i - 3] + 1;
}
while(scanf("%d", &n) != EOF) {
printf("%I64d\n", dp[n]);
}
return 0;
}