Yet Another Problem About Pi
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
long double pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
int main(){
int T;
cin>>T;
while(T--){
double x,y;
cin>>x>>y;
double cro=sqrt(x*x+y*y);
if(x>y) x=y;
if(x>pi) { cout<<"4"<<endl; continue; }
ll ans=4,xt=0,ct=0;
double xn=x/2, crn=cro/3;
if(xn<crn)
{
xt = ll(pi/x);
ans += xt*2;
if(pi-(xt-1)*x > cro) ans++;
}
else
{
ct = ll(pi/cro);
ans += ct*3;
if(pi-ct*cro >= x) ans+=2;
else if(pi-(ct-1)*cro >= 2*x) ans++;
}
cout<<ans<<endl;
}
return 0;
}
Robots
#include <iostream>
#include <bitset>
#include <vector>
#define MN 500
#define MQ 500000
//using namespace std;
typedef std::bitset<MN*MN> B;
using std::vector;
struct Query{
int opt,x,y,id;
};
bool ans[MQ+5];
char s[MN+5][MN+5];
B b[MN];
vector<Query> qs[MN][MN];
int main(){
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
scanf("%s",s[i]);
int q;
scanf("%d",&q);
for(int i=1;i<=q;i++){
int opt,x1,y1,x2,y2;
scanf("%d%d%d%d%d",&opt,&x1,&y1,&x2,&y2);
--x1,--y1,--x2,--y2;
qs[x1][y1].push_back({opt,x2,y2,i});
}
for(int i=n-1;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(s[i][j]=='0'){
if(s[i][j+1]=='0'){
b[j]|=b[j+1];
}
b[j][(i)*m+j]=1;
}else{
b[j].reset();
}
for(Query q:qs[i][j]){
if(q.opt==1){
ans[q.id]=(q.y==j&&b[j][(q.x)*m+q.y]);
}
if(q.opt==2){
ans[q.id]=(q.x==i&&b[j][(q.x)*m+q.y]);
}
if(q.opt==3){
ans[q.id]=b[j][(q.x)*m+q.y];
}
}
}
}
for(int i=1;i<=q;i++){
if(ans[i]){
printf("yes\n");
// cout<<"yes"<<endl;
}else{
printf("no\n");
// cout<<"no"<<endl;
}
}
return 0;
}