【数学】Chaarshanbegaan at Cafebazaar

本文介绍了一种使用智能屏幕和编程技术自动计算飞镖游戏得分的方法。通过输入飞镖击中点的坐标,程序能够根据距离原点的距离,参照得分表格,自动计算并累加玩家的总得分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目描述

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_JUDGE
    freopen("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;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值