A:签到
#include#include #include #include #include #include using namespace std;int read(){ int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') { if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f;}#define N 100010 int n,l,m;struct data{ int x,y;}a[N];int main(){ n=read(),l=read(),m=read(); for (int i=1;i<=n;i++) { int x=read(),y=read(); a[i].x=x,a[i].y=x+y; } a[0].x=a[0].y=0,a[n+1].x=a[n+1].y=l; int ans=0; for (int i=1;i<=n+1;i++) ans+=(a[i].x-a[i-1].y)/m; cout<
B:只能对于一个八个方向都被要求染色的位置染色。染完之后看一下和所要求的图是否相同就行了。
#include#include #include #include #include #include using namespace std;int read(){ int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') { if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f;}#define N 1010int n,m,a[N][N],b[N][N];int main(){ n=read(),m=read(); for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { char c=getchar(); while (c!='#'&&c!='.') c=getchar(); if (c=='#') a[i][j]=1; else a[i][j]=0; } } for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (a[i-1][j]&&a[i][j-1]&&a[i][j+1]&&a[i+1][j]&&a[i+1][j+1]&&a[i+1][j-1]&&a[i-1][j+1]&&a[i-1][j-1]) b[i-1][j]=b[i][j-1]=b[i][j+1]=b[i+1][j]=b[i+1][j+1]=b[i+1][j-1]=b[i-1][j+1]=b[i-1][j-1]=1; for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (a[i][j]!=b[i][j]) {cout<<"NO";return 0;} cout<<"YES"; return 0;}
C:要求字典序最大也就要求gcd的变化尽量早出现。如果n>=4,最容易使gcd增大的方法肯定是删掉所有奇数。所以递归删除即可。
#include#include #include #include #include #include using namespace std;int read(){ int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') { if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f;}#define N 1000010int n;void print(int n,int s){ if (n==1) {cout< >1;i++) printf("%d ",s); print(n>>1,s*2);}int main(){ n=read(); print(n,1); return 0;}
D:二分圆半径,对于每个圆就可以求出它所要求的圆心所在区间,判断一下有没有交。然而不知道是写挂还是卡精度了,一个半小时都没搞出来,惨炸。
//wa on 5#include#include #include #include #include #include using namespace std;int read(){ int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') { if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f;}#define N 100010int n;long double eps=1E-8;struct data{ int x,y;}a[N];struct data2{ long double x;int op; bool operator <(const data2&a) const { return x eps) { long double mid=(l+r)/2;bool flag=1; if (check(mid)) ans=mid,r=mid-eps; else l=mid+eps; } return ans;}int main(){ n=read(); long double flag1=0,flag2=0; for (int i=1;i<=n;i++) { a[i].x=read(),a[i].y=read(); if (a[i].y<0) flag2=1; if (a[i].y>1) flag1=1; } if (flag1&&flag2) {cout<<-1;return 0;} if (flag2) for (int i=1;i<=n;i++) a[i].y=-a[i].y; double ans=calc();printf("%.7lf",ans); return 0;}
E:好像很多人过然而还并没有看。
result:rank 329 rating -14