div2 5.26—5.27

1

#include<stdio.h>

#include<string.h>

int main()

{

    int  n,m,i,j,len;

    while(scanf("%d%d",&n,&m)!=EOF)

    {

     printf("%c",'+');

     for(i=0;i<n;i++)

     {

     printf("%c",'-');

}

printf("%c\n",'+');

for(j=0;j<m;j++)

{

for(i=0;i<n+2;i++)

{

if(i==0)

{

printf("%c",'|');

}

else if(i==n+1)

{

printf("%c\n",'|');

}

else

{

printf(" ");

}

}

}

printf("%c",'+');

     for(i=0;i<n;i++)

     {

     printf("%c",'-');

}

printf("%c\n",'+');

printf("\n");

}

return 0;

}

2

对于每组例子,输出连续的几个女朋友手中的玫瑰花总和为M的所有可能,以起始女朋友编号从小到大排序。

#看做数学问题解i=sqrt(2*m)估值,假设首项是1,我们代入m=a1*n+n*(n-1)/2,则有n(n+1)=2m(n是项数的个数)。

所以有n*(n+1)=2m>n*n,即n<sqrt(2m); 也就是说项数最多的情况也只有sqrt(2m)

#include<stdio.h>

 #include<math.h>

 int main()

 {

  int i,j,a1,m,n;

    while(scanf("%d%d",&n,&m)!=EOF&&(n!=0&&m!=0))

    {

     for(i=sqrt(2*m);i>0;i--)

     {

    a1=m/i-(i-1)/2;

    if(2*a1*i+i*i-i==2*m&&a1>0)

    {

    printf("[%d,%d]\n",a1,a1+i-1);

    }

}

printf("\n");

}

  return 0;

 }

3

An=(n-1)*(an-1+an-2)

求一串数排序没有一个数在规定位置的概率,即1/2!-1/3!+1/4!-1/5!...

#include<stdio.h>

double f(int x)

{

int i,num;

num=1;

for(i=2;i<=x;i++)

{

num*=i;

}

return 1.0/num;

}

int main()

{

int m,n,i,j;

double sum,t;

scanf("%d",&m);

for(i=0;i<m;i++)

{

scanf("%d",&n);

sum=0;t=1;

    if(n>1&&n<=20)

    {

     for(j=2;j<=n;j++)

     {

if(j%2==0)

{

t=f(j);

 }

 else

 {

  t=-f(j);

 }

sum+=t;

}

printf("%.2lf%%\n",sum*100);

}

}

return 0;

}

4

求一组时间段取最多时间段的个数

#include<stdio.h>

int main()

{

int n,i,j,t,a[1000],b[1000],count,last;

  while(scanf("%d",&n)!=EOF&&n!=0&&n<=100)

  {

   for(i=0;i<n;i++)

   {

   scanf("%d%d",&a[i],&b[i]);

  }

  for(i=1;i<n;i++)

  {

   for(j=0;j<i;j++)

   {

   if(b[i]<b[j])

   {

   t=a[i];a[i]=a[j];a[j]=t;

   t=b[i];b[i]=b[j];b[j]=t;

  }

  }

  }

  last=0;count=0;

  for(i=0;i<n;i++)

    {

     if(a[i]>=last)

     {

     count++;

     last=b[i];

}

}

printf("%d\n",count);

  }

return 0;

 }

4*

#include<iostream>

#include<stdio.h>

#include<algorithm>

using namespace std;

struct time

{

  int begin;

  int end;

};

bool cmp(time a,time b)  

{  

    return a.end < b.end;  

}  

int main()

{

  int n,i,t,last,begin,end;

  while(scanf("%d",&n)!=EOF&&n!=0)

  {

   struct time a[100000];

   for(i=0;i<n;i++)

   {

   scanf("%d%d",&a[i].begin,&a[i].end);

     }

   sort(a,a+n,cmp);

    t=0;

last=-1;

    for(i=0;i<n;i++)

    {

     if(a[i].begin>=last)

     {

     t++;

     last=a[i].end;

}

}

printf("%d\n",t);

  }

  return 0;

}

5

要测试多组数据,看清题

#include<stdio.h>

int main()

{

int n,i,d;

double a,s,x,y;

while(scanf("%d",&n)!=EOF)

{

x=0;y=0;

for(i=0;i<n;i++)

{

scanf("%lf%lf",&a,&s);

if(s==-1)

{

continue;

}

if(s<=100)

{

if(s>=90)

{

d=4;

}

else if(s>=80)

{

d=3;

}

else if(s>=70)

{

d=2;

}

else if(s>=60)

{

d=1;

}

else

{

d=0;

}

x+=d*a;

y+=a;

      }

 

   }  

if(x==0)

{

printf("-1\n");

    }

    else

    {

     printf("%.2lf\n",x/y);

}

}

return 0;

}

6

#include<stdio.h>

double f(char c,double a,double b)

{

    switch(c)

    {

        case '+': return a+b;break;

        case '-': return a-b;break;

        case '*': return a*b;break;

        case '/': return a/b;

    }

}

int main()

{

int d,n,i;

scanf("%d",&n);

if(n>0&&n<1000)

{

for(i=0;i<n;i++)

{

    getchar();

    char c;

double a,b;

scanf("%c%lf%lf",&c,&a,&b);

d=0;

    if(f(c,a,b)==int(f(c,a,b)))

    {

     d=int(f(c,a,b));

    printf("%d\n",d);

    }

    else

{

     printf("%.2lf\n",f(c,a,b));

}

    }

    }

    return 0;

}

7

求A^B的最后三位数表示的整数。

说明:A^B的含义是“A的B次方”

#include<stdio.h>    

int main()  

{    

    int a,b,i,x;    

    while(scanf("%d%d",&a,&b)!=EOF&&(a!=0&&b!=0))  

   {                       

        x=a;  

        a=1;  

        for(i=1;i<=b;i++)

        {  

             a=a%1000;  

             a=a*x;              

         }  

        printf("%d\n",a%1000);    

    }   

    return 0;   

}

8

1).密码长度大于等于8,且不要超过16。

(2).密码中的字符应该来自下面“字符类别”中四组中的至少三组。

这四个字符类别分别为:

1.大写字母:A,B,C...Z;

2.小写字母:a,b,c...z;

3.数字:0,1,2...9;

4.特殊符号:~,!,@,#,$,%,^;

给你一个密码,你的任务就是判断它是不是一个安全的密码。

#include<stdio.h>  

    #include<string.h>  

    int main()  

    {  

        int n,i;  

char a[10000];  

        scanf("%d",&n);  

        while(n--)  

        {  

            scanf("%s",a);  

            int len;

            bool b,c,d,e;

            b=c=d=e=false;

len=strlen(a);

            for(i=0;i<len;i++)  

            {  

                if(a[i]>=48&&a[i]<=57)  

           #0-9

                {   

                    b=true;  

                }  

                if(a[i]==64||a[i]==33||a[i]==35||a[i]==36||a[i]==37||a[i]==94||a[i]==126)  

                {  

                    c=true;  

                }  

                if(a[i]>=65&&a[i]<=90)  

#A-Z

                {  

                    d=true;

                }  

                if(a[i]>=97&&a[i]<=122)

#a-b

                {  

                    e=true;

                }  

            }  

            if(len>=8&&len<=16)

            {

             if((e&b&c)||(d&b&e)||(d&c&e)||(b&c&d))

             {

             printf("YES\n");

}

else

{

printf("NO\n");

}

}

            else

{

printf("NO\n");

}   

        }  

        return 0;

     }   

9

HDU1048

#include<stdio.h>

#include<string.h>

int main()

{

char a[30]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

char b[30]={'V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U'};

char c[100000],x[10000];

int i,j,m,t,len;

while(gets(x))

{

if(strcmp(x,"START")==0)

{

gets(c);

len=strlen(c);

for(j=0;j<len;j++)

{

for(m=0;m<26;m++)

{

if(c[j]==a[m])

{

c[j]=b[m];break;

}

}

}

puts(c);

    }

    if(strcmp(x,"ENDOFINPUT")==0)

        {

            break;

        }

    }

return 0;

}

9*

#include<stdio.h>

 #include<string.h>

 int main()

 {

  char a[10000],x[80000],s[100000];

  int j,len;

  while(gets(s)&&strcmp(s,"START")==0)

  {

  gets(a);

len=strlen(a);

for(j=0;j<len;j++)

{

if(a[j]>='F'&&a[j]<='Z')

{

a[j]-=5;

}

else if(a[j]>='A'&&a[j]<='E')

{

a[j]+=21;

}

else

{

continue;

}

}

   while(gets(s)&&strcmp(s,"END")==0)

  {

  puts(a);

   break;

   }

}

  return 0;

  }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Using: Intel (R) PRO Network Connections SDK v2.30.10 EEUPDATE v5.30.10.00 Copyright (C) 1995 - 2017 Intel Corporation Intel (R) Confidential and not for general distribution. ----------------------------------------------------- Options: /HELP or /? Displays command line help. /EXITCODES Displays exit code help. /ALL Selects all adapters found in the system. /NIC=XX Selects a specific adapter (1-32). /BUS=XX Selects PCI bus of adapter to program. Must be used with the DEV parameter to specify an adapter. /DEV=XX Selects PCI device of the adapter to program. Must be used with the BUS parameter to specify an adapter. /FUN=XX Selects PCI function of the adapter to program. Must be used with both the BUS and DEV parameters to specify an adapter. Press to continue... /DEVICE= 4 hex digit device id of card to program. /SUBDEVICE= 4 hex digit subsystem device id of card to program. /DUMP Dumps EEPROM/Shadow RAM memory contents to file *.eep and flash memory to *.bin (if available) /MAC_DUMP_FILE Dumps the MAC address to a file usable by the /A command. /MAC_DUMP Displays the adapter LAN MAC address. /MAC_DUMP_ALL Displays all the MAC addresses. /MAC_ALL_TO_FILE Dumps all the MAC addresses to a file usable by the /MAC_ALL_FROM_FILE command. /MAC_ALL_FROM_FILE Programs all MAC addresses from text file to a device. File should contain 13 MAC addresses (9 for PEPs and 4 custom MAC addresses), one each line. EUI48 and EUI64 formats accepted. /CB Clears bits in the EEPROM, specified in . /SB Sets bits in the EEPROM, specified in . Press to continue... /RW Reads from the EEPROM. /WW Writes into in EEPROM. /MAC=macaddr [/NUM=PF_num] Programs the EEPROM/NVM with only the MAC address of macaddr without changing the rest of the EEPROM/NVM. /NUM is optional and I40E specific - it defines target PF. /A or /address Programs the EEPROM/NVM with only the MAC address from the without changing the rest of the EEPROM. /D or /DATA Programs the NVM [EEPROM/FLASH] with the contents of without changing the MAC address. /PHYNVM Programs the PHY NVM with the contents of /DEBUG Forces debug update to be used where applicable. Must be used with /D or /DATA switch. /CALCCHKSUM Forces the EEPROM checksum and CRCs to be updated. Press to continue... /EEPROMVER Displays the version of the EEPROM image. /INVMVERSION Displays the version of the iNVM image. /PCIINFO Displays the PCI information of the adapter. /ADAPTERINFO Displays additional information about the adapter, such as EtrackID, PF MAC address, or image and firmware version. /TEST Checks the EEPROM/NVM checksum(s) and size. /IDFLASH Displays the flash ID and its protected status. /VERSION Displays version and the diagnostic library information. /PHYID Programs the PHY ID NVM with the contents of . /PHYID_DUMP Dumps PHY ID NVM contents to a file with the name: _.bin /PHYID_VERIFY Verifies the PHY ID NVM image in eeprom against the file specified in . Press to continue... /FLASH_DUMP Dumps contents of the whole flash memory of selected adapters to *.bin file /EEPROM_DUMP Dumps contents of the EEPROM/Shadow RAM memory of selected adapters to *.eep file /GUI Brings up GUI mode. /GUI /HELP Displays GUI help. /NOPROT When programming an image for devices that support NVM protection, prevents protection from being enabled. This switch must be used with the /DATA command and has no effect on NVM devices that are already protected. /DEBUGLOG Log debug messages into the debugfile. /VERIFY Verifies the eeprom/NVM image in eeprom/NVM to the target file specified in . Press to continue... /CHECKIMAGE Verifies that the NVM in can be loaded over the running NVM. /VERIFYPHYNVM Verifies the PHY NVM image in eeprom to the target file specified in . /ADAPTERRESET Reset the adapter. *CAUTION* This will unload the driver for this device if present. /SANMAC_DUMP [/NUM=PF_num] Displays the dedicated MAC address for the SAN. /NUM is optional and i40e specific - it defines target PF. /SANMAC=macaddr [/NUM=PF_num] Programs the dedicated SAN MAC address withoutchanging the rest of the EEPROM. /NUM is optional and i40e specific - it defines target PF. /SANADDRESS Programs the dedicated SAN MAC address with the MAC address from . /INVMVERIFY /FILE=] Compares autoload configuration stored in OTP memory with the configuration defined in configuration file. /INVMTEST /FILE=] Report number of free space left in INVM if autoload configuration defined in configuration file would be applied. Press to continue... /INVMUPDATE /FILE=] Write new autoload configuration defined in Raw (*.raw) configuration file to empty INVM or updates current autoload configuration stored in INVM based on 'human readable' configuration file. /INVMISLOCKED Checks if autoload configuration stored in OTP memory is protected against write attempts. /INVMLOCK Sets unique record in autoload configuration stored in INVM protecting its content against further updates. /INVMGET Dumps autoload configuration stored in INVM to file with predefined name .otp. /FORCE Omits any warnings and forces command execution. /KEEPCONFIG This option lets you keep config words while upgrading eeprom. /PORT_MAC=macaddr /NUM=Port_num Programs the dedicated Port MAC address without changing the rest of the EEPROM. /PORT_MAC_DUMP /NUM=Port_num Display the adapter port MAC address. Press to continue... /CUSTOM_MAC mac_number mac_addr Programs the given custom mac address number [0-3] without changing the rest of the NVM (EUI48 and EUI64 formats supported). /SERIAL_MAC=macaddr Programs the dedicated PCIe serial MAC address without changing the rest of the EEPROM. /SERIAL_MAC_DUMP Display the adapter PCIe serial MAC address. /PF_MAC=macaddr /NUM=PF_num Programs the dedicated MAC address of a specified Physical Function This allows altering the mac addresses of inactive functions of a visible NIC. /PF_MAC_DUMP /NUM=PF_num Display MAC address of a selected Physical Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /MNG_MAC=macaddr /NUM=MNG_num Programs the dedicated MAC address of a specified Manageability Function This allows altering the mac addresses of inactive functions of a visible NIC. /MNG_MAC_DUMP /NUM=MNG_num Display MAC address of a selected Manageability Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /RO Programs RO words in EEPROM/SR with values taken from RO Module binary file.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值