Ares, Toilet Ares
#include<iostream> #include<cstring> #include<queue> #include<map> #include<set> #include<algorithm> #include<cmath> #include<vector> #define fi first #define se second #define lowbit(x) (x&-x) using namespace std; namespace ae86{ const int bufl=1<<15; char buf[bufl],*s=buf,*t=buf; inline int fetch(){ if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;} return*s++; } inline int read(){ int a=0,b=1,c=fetch(); while(!isdigit(c))b^=c=='-',c=fetch(); while(isdigit(c))a=a*10+c-48,c=fetch(); return b?a:-a; } } using ae86::read; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,double> pid; const int inf=0x3f3f3f3f; const ll INF=2e18; const double eps=1e-8; const int mod=4933; ll qpow(ll a,ll b){ ll res=1; while(b){ if(b&1) res=res*a%mod; a=a*a%mod; b>>=1; } return res; } ll n,m,k,a,l; int main(){ scanf("%lld%lld%lld%lld%lld",&n,&m,&k,&a,&l); ll ans=a; ll x,y,z; ll tmp1=1; ll tmp2=1; for(int i=1;i<=k;i++){ scanf("%lld%lld%lld",&x,&y,&z); if(x==0) continue; tmp1=tmp1*(z-y)%mod; tmp2=tmp2*z%mod; } tmp1=ans*tmp2+tmp1; ans=tmp1*qpow(tmp2,mod-2)%mod; cout<<ans; }
Yet Another Problem About Pi
#include<iostream> #include<cstring> #include<queue> #include<map> #include<set> #include<algorithm> #include<cmath> #include<vector> #define fi first #define se second #define lowbit(x) (x&-x) using namespace std; namespace ae86{ const int bufl=1<<15; char buf[bufl],*s=buf,*t=buf; inline int fetch(){ if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;} return*s++; } inline int read(){ int a=0,b=1,c=fetch(); while(!isdigit(c))b^=c=='-',c=fetch(); while(isdigit(c))a=a*10+c-48,c=fetch(); return b?a:-a; } } using ae86::read; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,double> pid; const int inf=0x3f3f3f3f; const ll INF=2e18; const double eps=1e-8; const double pi=acos(-1); const int mod=1e9+7; int main(){ int T; cin>>T; while(T--){ double w,d; scanf("%lf%lf",&w,&d); double g=sqrt(w*w+d*d); w=min(w,d); int ans=4+(int)(pi/w)*2; for(int i=0;i<=50&&g*i<=pi;i++) ans=max(ans,4+int((pi-i*g)/w)*2+i*3); for(int i=0;i<=50&&w*i<=pi;i++) ans=max(ans,4+int((pi-i*w)/g)*3+i*2); cout<<ans<<endl; } }