这是一场爆0的比赛。。。。。。
第一题wa了20发,longlong改double再改unsigned long long还是wa,最后判断的时候改成除,边界设为1e19就过了
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-12; const int N=100000+10,maxn=500+100,inf=0x3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); cout<<setiosflags(ios::fixed)<<setprecision(0); unsigned long long l,r,k,s=1; cin>>l>>r>>k; bool f=0; for(int i=0;;i++) { // cout<<s<<endl; if(s>=l&&s<=r) { cout<<s<<" "; f=1; } if(1e19/s<k)break; s*=k; } if(!f)cout<<-1; cout<<endl; return 0; } /********************* 1 1000000000000000000 10 *********************/
A
A题python写超级简单= =
l,r,k=input().strip().split() s = 1 s = int(s) l = int(l) r = int(r) k = int(k) f = 0 for i in range(1000): if s>=l and s<=r: f = 1 print(s) elif s>r: break s*=k if f == 0: print(-1)
A python版
B正常直接相乘肯定t掉,转化成字符串记录0的个数
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-12; const int N=100000+10,maxn=500+100,inf=0x3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,zero=0; cin>>n; bool mulzero=0; string ans="1"; for(int i=0;i<n;i++) { string s; cin>>s; if(s.size()==1&&s[0]==‘0‘) { mulzero=1; continue; } bool ok=1; for(int j=0;j<s.size();j++) { if(j==0&&s[0]!=‘1‘)ok=0; else if(j!=0&&s[j]!=‘0‘)ok=0; } if(ok)zero+=(s.size()-1); else ans=s; } if(mulzero)cout<<0<<endl; else cout<<ans<<string(zero,‘0‘)<<endl; return 0; } /********************* *********************/
B
C计算几何,先扫点记录最大距离,再扫边记录最小距离(先判断点到边能不能直接计算最短距离)
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-12; const int N=100000+10,maxn=500+100,inf=0x3f3f3f; struct point{ double x,y; point(){} point(double _x,double _y):x(_x),y(_y){} }p[N]; double dis(point p1,point p2) { return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y)); } double linedis(point p1,point p2,point p3) { double a1=p3.y-p2.y,b1=-(p3.x-p2.x),c1=-p3.x*(p3.y-p2.y)+p3.y*(p3.x-p2.x); double a2=p3.x-p2.x,b2=p3.y-p2.y,c2=-p1.x*(p3.x-p2.x)-p1.y*(p3.y-p2.y); double x,y; if(a1==0&&a2!=0) { y=-c1/b1,x=(-b2*y-c2)/a2; } else if(a1!=0&&a2==0) { y=-c2/b2,x=(-b1*y-c1)/a1; } else { x=(b1*c2-b2*c1)/(b2*a1-b1*a2); if(b1==0)y=(-a2*x-c2)/b2; else y=(-a1*x-c1)/b1; } /* cout<<a1<<" "<<b1<<" "<<c1<<endl; cout<<a2<<" "<<b2<<" "<<c2<<endl; cout<<x<<" "<<y<<endl;*/ point p(x,y); if((p2.x<x&&x<p3.x)||(p3.x<x&&x<p2.x))return dis(p,p1); if((p2.y<y&&y<p3.y)||(p3.y<y&&y<p2.y))return dis(p,p1); return min(dis(p1,p2),dis(p1,p3)); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout<<setiosflags(ios::fixed)<<setprecision(10); int n; point o; cin>>n>>o.x>>o.y; for(int i=0;i<n;i++) cin>>p[i].x>>p[i].y; p[n]=p[0]; double minn=1e7,maxx=0; for(int i=0;i<n;i++) { maxx=max(maxx,dis(o,p[i])); minn=min(minn,linedis(o,p[i],p[i+1])); } // cout<<maxx<<" "<<minn<<endl; cout<<(maxx-minn)*(maxx+minn)*pi<<endl; return 0; } /********************* 3 0 0 -1 1 0 3 1 1 3 -3 3 -3 2 5 -5 5 3 *********************/
C
时间: 2024-12-20 01:04:42