題目描述
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;
}
?