题目描述
Chaarshanbegaan is a gathering event at Cafebazaar similar to TGIF events at Google. Some entertainment programs like pantomime, foosball, Xbox/PS4, and several board games are part of the event. You are going to set up a dart game in Chaarshanbegaan. As a techie organizing a game for techies, you would rather use a smart screen and write a program to calculate the scores instead of hanging a traditional dartboard and scoring the shots manually. Your program must get the coordinates of dart shots for a player and calculate his/her total score. The score for each dart shot (at point (x, y)) is calculated based on its distance from the center of the dartboard (point (0, 0)). If the distance is d millimeters, the score is calculated based on the following table:
输入
The first line of the input contains a single integer N as the number of dart shots for a player (1 ⩽ N ⩽ 100). Each of the next N lines contains two space-separated integers as the coordinates (x, y) of a dart shot. The coordinates are in millimeters and their absolute values will not be greater than 300.
输出
Print a single line containing the total score of the player.
题目大意:
先输入一个整数,代表掷飞镖的次数,下面n行每行输入两个整数,代表掷飞镖中的位置的坐标,根据飞镖掷中的位置与原点的距离,可以查表得到不同的分数,问最终能得几分。
解题思路:
根据位置判断所得分数,加起来即可。
代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int t;cin>>t;int ans=0;while(t--) {double x,y;cin>>x>>y;double d=sqrt(x*x+y*y);if(d<=10) ans+=10;else if(d<=30) ans+=9;else if(d<=50) ans+=8;else if(d<=70) ans+=7;else if(d<=90) ans+=6;else if(d<=110) ans+=5;else if(d<=130) ans+=4;else if(d<=150) ans+=3;else if(d<=170) ans+=2;else if(d<=190) ans+=1;else ans+=0;}cout<<ans<<endl;return 0;
}