Codeforces Round #430 (Div. 2) B. Gleb And Pizza
2017-08-30 01:08
417 查看
比较水的题
一开始想多了 加了几个特判 反倒是过不了了
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<cmath>
#include<stack>
#include<list>
#include<map>
#include<set>
typedef long long ll;
#define exp 1e-8
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
const int MAXN=1005;
const int mod=10007;
const int inf=0x3f3f3f3f;
int main()
{
int i,j,k,m,n;double d,r;
scanf("%lf%lf",&r,&d);
int ans=0;
scanf("%d",&n);
double x,y,z;
int T=n;
while(T--)
{
scanf("%lf%lf%lf",&x,&y,&z);
double t=1.0*x*x+1.0*y*y;
double dis=sqrt(t);
if(dis+z<=r)
{
if(dis-z>=r-d)
{
ans++;
}
}
}
printf("%d",ans);
return 0;
}
一开始想多了 加了几个特判 反倒是过不了了
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<cmath>
#include<stack>
#include<list>
#include<map>
#include<set>
typedef long long ll;
#define exp 1e-8
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
const int MAXN=1005;
const int mod=10007;
const int inf=0x3f3f3f3f;
int main()
{
int i,j,k,m,n;double d,r;
scanf("%lf%lf",&r,&d);
int ans=0;
scanf("%d",&n);
double x,y,z;
int T=n;
while(T--)
{
scanf("%lf%lf%lf",&x,&y,&z);
double t=1.0*x*x+1.0*y*y;
double dis=sqrt(t);
if(dis+z<=r)
{
if(dis-z>=r-d)
{
ans++;
}
}
}
printf("%d",ans);
return 0;
}
相关文章推荐
- Codeforces Round #430 (Div. 2) B. Gleb And Pizza
- Codeforces Round #430 (Div. 2) B. Gleb And Pizza(数论)
- Codeforces Round #430 (Div. 2) B. Gleb And Pizza
- 【Codeforces Round #430 (Div. 2) B】Gleb And Pizza
- Codeforces Round #430 B. Gleb And Pizza
- Codeforces Round #430 (Div. 2) E. Nikita and game
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree(补题)
- Codeforces Round #430 (Div. 2) Vitya and Strange Lesson
- Codeforces Round #430 (Div. 2) D - Vitya and Strange Lesson(补题,01Trie)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree
- 【Codeforces Round #430 (Div. 2) D】 D. Vitya and Strange Lesson ("带lazy" 的字典树)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- Codeforces Round #430 (Div. 2) A. Kirill And The Game
- Codeforces Round #430 (Div. 2) D. Vitya and Strange Lesson(01Trie)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree(dfs)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree(dfs+最大公约数+因子+树)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree
- Codeforces Round #430 (Div. 2) - C. Ilya And The Tree (树形DFS)