当前位置:   article > 正文

芬兰木棋 (25 分)

芬兰木棋 (25 分)

robocom初赛B题

//32位整数-2147483628~2147483647
//绝对值后就超过int范围
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
map<PII, vector<PII> >mp;
int n;
LL sum,cnt;

int gcd(LL a, LL b)
{
    return b?gcd(b,a%b):a;
}

int main()
{
    scanf("%d", &n);
    while (n -- )
    {
        LL a,b;
        int c;
        scanf("%lld%lld%d",&a,&b,&c);
        sum+=c;
        int d = gcd(abs(a),abs(b));
        mp[{b/d, a/d}].push_back({a*a+b*b,c});
    }
    for(auto i=mp.begin();i!=mp.end();i++)
    {
        vector<PII> v = i->second;
        sort(v.begin(),v.end());
        for(int j=0;j<v.size();j++)
        {
            if(v[j].second!=1) cnt++;
            else
            {
                if(v[j].second!=v[j+1].second&&j<v.size()) cnt++;
            }
        }
    }
    printf("%lld %lld\n",sum,cnt);
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/900970?site=
推荐阅读
相关标签
  

闽ICP备14008679号