A - Wasted Time
B - Canvas Frames
有N根木棍,找出能组成矩形的个数,木棍不能重复使用。
在直角坐标系中画折线,并且画K次,画的速度是50,求时间- -b
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
struct node{
double x, y;
}l[105];
double dis(node a, node b)
{
return sqrt(0.0 + (a.x - b.x) * (a.x - b.x) + (a.y - b.y) *(a.y - b.y));
}
int main()
{
int n, k;
while(scanf("%d %d", &n, &k) != EOF){
int i;
double s = 0;
for(i = 0; i < n; ++i){
scanf("%lf%lf", &l[i].x, &l[i].y);
}
for(i = 1; i < n; ++i){
s += dis(l[i - 1], l[i]);
}
printf("%.7lf\n", s * k / 50);
}
return 0;
}
B - Canvas Frames
有N根木棍,找出能组成矩形的个数,木棍不能重复使用。
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
int hash[105];
int main()
{
int n;
while(scanf("%d", &n) != EOF){
int i, t;
memset(hash, 0, sizeof(hash));
for(i = 0; i < n; ++i){
scanf("%d", &t);
hash[t]++;
}
int ans = 0;
for(i = 1; i <= 100; ++i){
ans = ans + hash[i] / 2;
}
printf("%d\n", ans / 2);
}
return 0;
}