Fifth_Training

void test(int n)
{
    a[1]=0;a[2]=0,a[3]=0;
    int flag,i,j;
    for(i=4;i<20;i++)
    {
        flag=0;
        for(j=1;j<=(i/3);j++)
         if(a[i-j]==0)
         {
            flag=1;
            break;
         }
        a[i]=flag;
    }


    for(i=1;i<n;i++)cout<<i%10<<" ";
    cout<<endl;
    for(i=1;i<n;i++)
      cout<<a[i]<<" ";
    cout<<endl;
}



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;


#define G 9.81


int main()
{
    double k,l,h,w;
    double v;
    while(~scanf("%lf%lf%lf%lf",&k,&l,&h,&w))
    {
        if(k==0&&l==0&&h==0&&w==0)
            break;
        double e=w*G*h;//重力势能
        if(h>l)e-=k*(h-l)*(h-l)/2;//弹性势能
        if(e<0)//绳子太短,停在空中
        {
            printf("Stuck in the air.\n");
        }
        else
        {
            v=sqrt(2*e/w);
            if(v>10.0)
              printf("Killed by the impact.\n");
            else
              printf("James Bond survives.\n");
        }
    }


    return 0;
}





#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define M 1000002
char str[M];
int  next[M];
void show(int n)
{
    for(int i=0;i<n;i++)
        cout<<next[i]<<" ";
    cout<<endl;
}
int getnext(int n)
{
    int i=0,k=-1;
    int  ans=1;
    memset(next,0,sizeof(next));
    next[0]=-1;
    while(i<n)
    {
        if(k==-1||str[i]==str[k])
        {
            i++;k++;
            if( str[i]!=str[k])
                next[i]=k;
            else
                next[i]=next[k];
        }
        else
        {
            k=next[k];
        }
    }
    i=n-k;
    if(n%i==0)
       return n/i;
    else
       return  1;
}
int main()
{
    while(~scanf("%s",str))
    {
        if(str[0]=='.')
            break;
        int len=strlen(str);
        cout<<getnext(len)<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值