群賽53

來源:互聯網
上載者:User

很久沒做群賽...秀逗了.

A水:

#include<stdio.h>#include<string.h>int main(){    char a[33];    int counter;    while(~scanf("%s",a)){        if(a[0]=='#') break;        counter=0;        int len=strlen(a);        for(int i=0;i<len;i++){            if(a[i]=='1') counter++;        }        if(counter%2==0){            if(a[len-1]=='e') a[len-1]='0';            if(a[len-1]=='o') a[len-1]='1';        }        else {            if(a[len-1]=='e') a[len-1]='1';            if(a[len-1]=='o') a[len-1]='0';        }        printf("%s\n",a);    }}

B是閱讀題T_T:

#include<stdio.h>#include<math.h>typedef struct{    double x,y;}node;node s,t,ans;double dis(node a,node b){    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){    int i,I=1,d;    double r,du;   while( scanf("%lf",&r)!=EOF)   {    scanf("%lf%lf",&s.x,&s.y);    if(r==0&&s.x==0&&s.y==0)break;    i=1;    d=0;    while(scanf("%lf%lf",&t.x,&t.y)!=EOF)    {        if(t.x==-1&&t.y==-1)break;        du=dis(s,t);        if(du<=r+1&&0==d)        {            ans=t;            d=1;        }        s.x+=(t.x-s.x)*(r/du);        s.y+=(t.y-s.y)*(r/du);        i++;    }    printf("Firefly %d ",I++);    if(0==d)printf("not caught\n");    else printf("caught at (%.0lf,%.0lf)\n",ans.x,ans.y);   }   return 0;}

CDEFG沒看

因為H一直PE,,,字串的題目太噁心了...

後來看了一個大神的代碼,,,大讚...

貼下:

using namespace std;char decode[]=" ABCDEFGHIJKLMNOPQRSTUVWXYZ',-.?";int main(){    int spaces=0;    int bits=0;    int code=0;    char c;    while((c=getchar())!='#'){    if(c==' ') ++spaces;    else{    if(spaces>0){    code=(code<<1)+1-(spaces&1);//當space為為偶數時,與上1變成0,+1,當space為奇數時與上1為1,+0    spaces=0;    if(++bits==5){    cout<<decode[code];    code=bits=0;}    }    if(c=='*'){     if(bits>0){     cout<<decode[code<<(5-bits)];     code=bits=0;}     cout<<endl;}}}     return 0;}

I題好難,一開始還YY線段樹,然後又覺得背包-.-結果到最後也沒人做出

J題籤到題:

#include<stdio.h>int main(){    int a,b;    while(~scanf("%d%d",&a,&b)){        printf("%d %d\n",b-1,a-1);    }    return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.