Codeforces #430 dv.2 842A ,842B
来源:互联网 发布:交易训练软件 编辑:程序博客网 时间:2024/06/06 19:53
0 0 两道题,
#include <iostream>#include <stdio.h>#include <algorithm>#include <cmath>#include <cstring>#include <string>#include <queue>#include <stack>#include <stdlib.h>#include <list>#include <map>#include <set>#include <bitset>#include <vector>#define mem(a,b) memset(a,b,sizeof(a))#define findx(x) lower_bound(b+1,b+1+bn,x)-b#define FIN freopen("input.txt","r",stdin)#define FOUT freopen("output.txt","w",stdout)#define S1(n) scanf("%d",&n)#define SL1(n) scanf("%I64d",&n)#define S2(n,m) scanf("%d%d",&n,&m)#define SL2(n,m) scanf("%I64d%I64d",&n,&m)#define Pr(n) printf("%d\n",n)using namespace std;typedef long long ll;const double PI=acos(-1);const int INF=0x3f3f3f3f;const double esp=1e-6;const int maxn=1e6+5;const int MOD=1e9+7;const int mod=1e9+7;int dir[5][2]={0,1,0,-1,1,0,-1,0};ll inv[maxn*2],fac[maxn];ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}void INV(){inv[1] = 1;for(int i = 2; i < maxn; i++) inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;}void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);}}void Fac(){fac[0]=1;for(int i=1;i<=maxn;i++)fac[i]=(fac[i-1]*i)%MOD;}ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}ll inv2(ll b){return qpow(b,MOD-2);}ll cal(ll m,ll n){if(m<n)return 0;return (fac[m]*inv[fac[n]]%MOD)%MOD*inv[fac[m-n]]%MOD;}ll cals(ll m,ll n){if(m<n)return 0;return (fac[m]*inv1(fac[n])%MOD)%MOD*inv1(fac[m-n])%MOD;}int main(){ ll l,r,x,y,k; while(~scanf("%I64d %I64d %I64d %I64d %I64d",&l,&r,&x,&y,&k)) { int flag=0; for(ll i=x;i<=y;i++) { ll temp=k*i; if(l<=temp&&temp<=r) { flag=1; break; } } if(flag) printf("YES\n"); else printf("NO\n"); } return 0;}
Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.
The pizza is a circle of radius r and center at the origin. Pizza consists of the main part — circle of radius r - d with center at the origin, and crust around the main part of the width d. Pieces of sausage are also circles. The radius of the i -th piece of the sausage is ri, and the center is given as a pair (xi, yi).
Gleb asks you to help determine the number of pieces of sausage caught on the crust. A piece of sausage got on the crust, if it completely lies on the crust.
First string contains two integer numbers r and d (0 ≤ d < r ≤ 500) — the radius of pizza and the width of crust.
Next line contains one integer number n — the number of pieces of sausage (1 ≤ n ≤ 105).
Each of next n lines contains three integer numbers xi, yi and ri ( - 500 ≤ xi, yi ≤ 500, 0 ≤ ri ≤ 500), where xi and yi are coordinates of the center of i-th peace of sausage, ri — radius of i-th peace of sausage.
Output the number of pieces of sausage that lay on the crust.
8 477 8 1-7 3 20 2 10 -2 2-3 -3 10 6 25 3 1
2
10 840 0 90 0 101 0 11 0 2
0
Below is a picture explaining the first example. Circles of green color denote pieces of sausage lying on the crust.
判断 在不在圆环里, 瞪着眼睛 愣是把 d 看成里面圆的半径, 更 可笑的是 还 过了5 个数据- -
#include <iostream>#include <stdio.h>#include <algorithm>#include <cmath>#include <cstring>#include <string>#include <queue>#include <stack>#include <stdlib.h>#include <list>#include <map>#include <set>#include <bitset>#include <vector>#define mem(a,b) memset(a,b,sizeof(a))#define findx(x) lower_bound(b+1,b+1+bn,x)-b#define FIN freopen("input.txt","r",stdin)#define FOUT freopen("output.txt","w",stdout)#define S1(n) scanf("%d",&n)#define SL1(n) scanf("%I64d",&n)#define S2(n,m) scanf("%d%d",&n,&m)#define SL2(n,m) scanf("%I64d%I64d",&n,&m)#define Pr(n) printf("%d\n",n)using namespace std;typedef long long ll;const double PI=acos(-1);const int INF=0x3f3f3f3f;const double esp=1e-6;const int maxn=1e6+5;const int MOD=1e9+7;const int mod=1e9+7;int dir[5][2]={0,1,0,-1,1,0,-1,0};struct node{ll x,y,r;ll ed;}a[maxn];int main(){ int r,d,n; while(~scanf("%d %d",&r,&d)) { mem(a,0);scanf("%d",&n);ll ans=0;for(int i=1;i<=n;i++){scanf("%I64d %I64d %I64d",&a[i].x,&a[i].y,&a[i].r);a[i].ed=(a[i].x*a[i].x+a[i].y*a[i].y);if((r-d+a[i].r)*(r-d+a[i].r)<=a[i].ed&&((r-a[i].r)*(r-a[i].r))>=a[i].ed){ans++;}}printf("%I64d\n",ans); } return 0;}
- Codeforces #430 dv.2 842A ,842B
- codeforces round#404(dv.2) B. Anton and Classes
- Codeforces Round #430 (Div. 2)A,B
- Codeforces Round #430 (Div. 2) A B C D
- Codeforces Round #430 (Div. 2)(A+B+C)
- Codeforces 842B
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #185 (Div. 2)--A,B
- CodeForces#211(Div.2) - A,B,C
- Codeforces Round #216 (Div. 2) A.B
- Codeforces Beta Round #2 A B C
- Codeforces round #236Div.2--A;B
- Codeforces Round #236 (Div. 2)------A,B
- Codeforces Round #237 (Div. 2) A & B
- Codeforces Round #247 (Div. 2) A B
- Codeforces Round #251 (Div. 2) A~B
- Codeforces Round #249 (Div. 2) A B
- Codeforces Round #271 (Div. 2)-A.B
- 1101 第1课
- [cvpr2017]Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
- 十进制大数的加法运算
- 避免函数中过深的耦合
- main函数之前做的工作
- Codeforces #430 dv.2 842A ,842B
- ggplot2之Layer—— geoms(二)
- hive笔记
- 校内赛 codeforces 827D【最小生成树】【树链剖分】 解题报告
- 编程获取linux的CPU使用率内存占用率
- Android 动画知识相关图谱
- 上台阶问题(跳法+路径)
- mybatis,初级入门
- Q*Layout