杭电oj2000开始的100道部分代码

2019/7/3

2019
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
int main(void)
{
    int a[105];
   int n,m;
   while(cin>>n>>m)
   {
       if(n==0&&m==0) break;
       int k,k1;
       for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]>=m){
                k=i;
                k1=m;
                m=MAX_INT;
            }
       }
        for(int i=0;i<k;i++){
            cout<<a[i]<<" ";
        }
        cout<<k1;
        for(int i=k;i<n;i++){
            cout<<" "<<a[i];
        }
        cout<<endl;
   }

	return 0;
}

2020
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    int a[105];
   int n;
   while(cin>>n)
   {
       if(n==0) break;
       for(int i=0;i<n;i++){
            cin>>a[i];
       }
       for(int i=0;i<n;i++)
       for(int j=1;j<n;j++){
            if(abs(a[j-1])<abs(a[j])){
                int s=a[j-1];
                a[j-1]=a[j];
                a[j]=s;
            }

       }
       for(int i=0;i<n-1;i++)
            cout<<a[i]<<" ";
       cout<<a[n-1]<<endl;
   }

	return 0;
}

2021
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{

   int n;
   while(cin>>n)
   {
       if(n==0) break;
       int num=0;

        int k;
        for(int i=0;i<n;i++){
                int a100=0,a50=0,a10=0,a5=0,a2=0,a1=0;
            cin>>k;
            if(k>=100){
                a100=k/100;
                k=k%100;
            }
            if(k>=50){
                a50=k/50;
                k%=50;
            }
            if(k>=10){
                a10=k/10;
                k%=10;
            }
             if(k>=5){
                a5=k/5;
                k%=5;
            }
             if(k>=2){
                a2=k/2;
                k%=2;
            }
             a1=k;
             num+=a100+a50+a10+a5+a2+a1;
        }
        cout<<num<<endl;
   }

	return 0;
}

2022
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{

   int n,m;
   while(cin>>m>>n)
   {
       int h=1,l=1;
       int k=0,a;
       for(int i=1;i<=m;i++)
       for(int j=1;j<=n;j++){
            cin>>a;
            if(abs(a)>abs(k)){
                k=a;
                h=i;
                l=j;
            }
       }
       cout<<h<<" "<<l<<" "<<k<<endl;
   }

	return 0;
}

2023
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    double p[105][6];
    double a[105];
   int n,m;
   while(cin>>n>>m)
   {
       for(int j=0;j<n;j++){
        double num=0;
       for(int i=0;i<m;i++){
            cin>>p[j][i];
            num+=p[j][i];
       }
            a[j]=num/m;
    }
    for(int i=0;i<n-1;i++)
        printf("%.2f ",a[i]);
    printf("%.2f\n",a[n-1]);

        for(int i=0;i<m;i++){
                double num=0;
        for(int j=0;j<n;j++){
            num+=p[j][i];
        }
        a[i]=num/n;
        }
        for(int i=0;i<m-1;i++)
        printf("%.2f ",a[i]);
    printf("%.2f\n",a[m-1]);
    int num=0;
    for(int i=0;i<n;i++){
            int gg=0;
        for(int j=0;j<m;j++){
            if(p[i][j]>=a[j])
            gg++;
        }
        if(gg==m)
            num++;
    }
    cout<<num<<endl<<endl;
   }
	return 0;
}
2024
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    int k;
    while(cin>>k)
    {

                getchar();
        for(int i=0;i<k;i++){
                char a[55];

                gets(a);
        int q=1;
        if(a[0]>='0'&&a[0]<='9') q=0;
         for(int j=0;j<strlen(a);j++){
            if(!((a[j]>='0'&&a[j]<='9')||(a[j]>='A'&&a[j]<='Z')||(a[j]>='a'&&a[j]<='z')||(a[j]=='_'))) q=0;
        }
        if(q) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }}

	return 0;
}
2025
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    string s;
    while(cin>>s)
    {
        char max=s[0];
        for(int i=1;i<s.length();i++)
            if(max<s[i])
            max=s[i];//max代表最大元素
        for(int i=0;i<s.length();i++)
        {
            cout<<s[i];
            if(s[i]==max)//遍历字符串,遇到最大元素时
                cout<<"(max)";
        }
        cout<<endl;
    }
	return 0;
}
2026
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    char s[105];
    while(gets(s))
    {
        int k=1;
        for(int i=0;i<strlen(s);i++){
            if(k){
                k=0;
                s[i]=s[i]-32;
                }
            else if(s[i]==' '){
                k=1;
            }
        }
        cout<<s<<endl;

    }
	return 0;
}
2027
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)

int main(void)
{
    int n;
    cin>>n;
    getchar();
    for(int i=0;i<n;i++){
        char a;
        int aa=0,ee=0,ii=0,oo=0,uu=0;

        while((a=getchar())!='\n'){
            if(a=='a') aa++;
            if(a=='e') ee++;
            if(a=='o') oo++;
            if(a=='u') uu++;
            if(a=='i') ii++;
        }
        cout<<"a:"<<aa<<endl;
        cout<<"e:"<<ee<<endl;
        cout<<"i:"<<ii<<endl;
        cout<<"o:"<<oo<<endl;
        cout<<"u:"<<uu<<endl;
        if(i!=n-1)
            cout<<endl;
    }
	return 0;
}
2028
#include 
#include 
#include 
#include"stdio.h"
#include 
using namespace std;
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)


long g(long a,long b)
{

    if(b==0) return a;
    return g(b,a%b);
}

int main(void)
{

    int n;
    while(cin>>n){
    int a,b;
    cin>>a;
    long p=a;
    for(int i=1;i<n;i++){
        cin>>b;
        p=p/ g(p, b) * b ;//这里要注意要先除再乘,会越界,不然答案错误。
    }
    cout<<p<<endl;
    }
	return 0;
}
2029
#include 
#include 
#include 
#include"stdio.h"
#include 
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        char s[1000];
        cin>>s;
        int a2=strlen(s)-1;
        int aa=strlen(s);
        int k=1;
        for(int a1=0;a1<aa;a1++){
                if(a1==a2||abs(a1-a2)==1) break;
            if(s[a1]!=s[a2]){
                k=0;
                break;
            }
            a2--;
        }
        if(k) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

7/4

2030
#include 
#include 
#include 
#include"stdio.h"
#include 
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    cin>>n;
        getchar();
    for(int j=0;j<n;j++){
        char a[1000];

        int num=0;
        gets(a);
            int k=strlen(a);
            for(int i=0;i<k;i++){
                if(a[i]<0) num++;
            }
            cout<<num/2<<endl;
    }
    return 0;
}
2031
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n,q;
    while(cin>>n>>q)
    {
        int k=1;
        if(n<0){
            k=0;
            n=-n;
        }
        int a[1000];
        int i=0;
        while(n){
            a[i]=n%q;
            i++;
            n=n/q;
        }
        if(!k) cout<<"-";
        for(i--;i>=0;i--){
            if(a[i]==10) cout<<'A';
            else if(a[i]==11) cout<<'B';
            else if(a[i]==12) cout<<'C';
            else if(a[i]==13) cout<<'D';
            else if(a[i]==14) cout<<'E';
            else if(a[i]==15) cout<<'F';
            else cout<<a[i];
        }
        cout<<endl;
    }
    return 0;
}
2032
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        int a[31][31];
        for(int i=0;i<n;i++){
            a[i][i]=1;
            a[i][0]=1;
        }
        for(int i=2;i<n;i++){
            for(int j=1;j<i;j++){
                a[i][j]=a[i-1][j]+a[i-1][j-1];
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<=i;j++){
                if(j==i) cout<<1<<endl;
                else cout<<a[i][j]<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}
2033
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++){
            int a1,a2,a3,b1,b2,b3;
            cin>>a1>>a2>>a3>>b1>>b2>>b3;
            if((a3+b3)>59){
                a3=a3+b3-60;
                a2++;
            }
            else a3=a3+b3;
            if((a2+b2)>59){
                a2=a2+b2-60;
                a1++;
            }
            else a2=a2+b2;
            cout<<a1+b1<<" "<<a2<<" "<<a3<<endl;
        }
    }
    return 0;
}
2034
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0&&m==0) break;
        int a[101],b[101];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<m;i++){
            cin>>b[i];
        }
        sort(a,a+n);
        sort(b,b+m);
        int k=0,q=0;
        for(int i=0;i<n;i++){
                if(m==0){    //考虑m为0的情况,不会进入循环
                    q=1;
                    cout<<a[i]<<" ";
                }
            for(int j=k;j<m;j++){
                if(a[i]==b[j]){
                    k=j+1;
                    break;
                }
                else if(b[j]>a[i]){
                    q=1;
                    cout<<a[i]<<" ";
                    break;
                }
            }
        }
        if(!q) cout<<"NULL";
        cout<<endl;
    }
    return 0;
}

7/5

2035
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0&&m==0) break;
        int k=1;
        for(int i=0;i<m;i++){
            k=k*n;
            k=k%1000;
        }
        cout<<k<<endl;
    }
    return 0;
}
2036
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;
int x[101],y[101];
int  s(int x1,int y1,int x2,int y2)
{
    return x1*y2-x2*y1;//2s=x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2
}
int main(void)
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        for(int i=1;i<=n;i++){
            cin>>x[i]>>y[i];
        }
        int num=0;
        for(int i=1;i<=n-1;i++){
            num+=s(x[i],y[i],x[i+1],y[i+1]);
        }
        num+=s(x[n],y[n],x[1],y[1]);
        if(num%2==0) cout<<num/2<<".0"<<endl;
        else cout<<num/2<<".5"<<endl;
    }
    return 0;
}
2037
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        int a[101],b[101];
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
        }
        for(int i=0;i<n-1;i++){
            for(int j=1;j<n;j++){
                if(b[j-1]>b[j]){
                    swap(a[j],a[j-1]);
                    swap(b[j],b[j-1]);
                }
            }
        }
        for(int i=1;i<n;i++){
                int k=i-1;
            while(b[i]==b[i-1]){
                i++;
            }
            for(int q=k;q<i;q++)
            for(int j=k+1;j<i;j++){//防止数组越界
                if(a[j-1]>a[j]){
                    swap(a[j],a[j-1]);
                }
            }
        }
        int num=1;
        int p=b[0];
        for(int i=1;i<n;i++){
            if(a[i]>=p){
                num++;
                p=b[i];
            }
        }
        cout<<num<<endl;
    }
    return 0;
}
2039
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        double a,b,c;
        for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(a+b>c&&a+c>b&&b+c>a)
            cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        }
    }
    return 0;
}
2040
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        int a,b;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            int num=0;
            for(int j=1;j<=a/2;j++){
                if(a%j==0) num+=j;
            }
            if(num==b){
                num=0;
                for(int j=1;j<=b/2;j++){
                if(b%j==0) num+=j;
            }
            if(num==a) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            }
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}
2041
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int aa[41];
    aa[2]=1;
    aa[3]=2;
    for(int i=4;i<=41;i++)
        aa[i]=aa[i-1]+aa[i-2];
    int n;
    while(cin>>n)
    {
        int a;
        for(int i=0;i<n;i++){
            cin>>a;
            cout<<aa[a]<<endl;
        }
    }
    return 0;
}
2043
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        getchar();
        for(int i=0;i<n;i++){
            char s[50];
            cin>>s;
            int a1=0,a2=0,a3=0,a4=0;
            int l=strlen(s);
            if(l>=8&&l<=16){
                for(int j=0;j<l;j++){
                    if(s[j]>='A'&&s[j]<='Z') a1=1;
                    if(s[j]>='a'&&s[j]<='z') a2=1;
                    if(s[j]>='0'&&s[j]<='9') a3=1;
                    if(s[j]=='~') a4=1;
                    if(s[j]=='!') a4=1;
                    if(s[j]=='@') a4=1;
                    if(s[j]=='#') a4=1;
                    if(s[j]=='$') a4=1;
                    if(s[j]=='%') a4=1;
                    if(s[j]=='^') a4=1;
                    if(a1+a2+a3+a4>=3){
                        cout<<"YES"<<endl;
                        break;
                    }
                }
                if(a1+a2+a3+a4<3)
                cout<<"NO"<<endl;
            }
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

7/6

2044
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long aa[50];
    aa[1]=1;aa[2]=2;
    for(int i=3;i<=49;i++)
        aa[i]=aa[i-1]+aa[i-2];
    int n;
    while(cin>>n)
    {
        int a,b;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            cout<<aa[b-a]<<endl;
        }
    }
    return 0;
}
2045
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long aa[51]; //第n-1个格子考虑是不是和第一相同颜色
    aa[1]=3;aa[2]=6;aa[3]=6;//不是的话就有A【n-1】种
    for(int i=4;i<=50;i++)//是的话就有2*A【n-2】种
        aa[i]=aa[i-1]+2*aa[i-2];
    int n;
    while(cin>>n)
    {
        cout<<aa[n]<<endl;
    }
    return 0;
}
2046
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long aa[51]; 
    aa[1]=1;aa[2]=2;aa[3]=3;
    for(int i=4;i<=50;i++)
        aa[i]=aa[i-1]+aa[i-2];
    int n;
    while(cin>>n)
    {
        cout<<aa[n]<<endl;
    }
    return 0;
}
2047
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long aa[51]; 
    aa[1]=3;aa[2]=8;
    for(int i=3;i<=40;i++)
        aa[i]=2*(aa[i-1]+aa[i-2]);
    int n;
    while(cin>>n)
    {
        cout<<aa[n]<<endl;
    }
    return 0;
}
2048
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long int aa[21];
    aa[1]=0;aa[2]=1;aa[3]=2;
    for(int i=4;i<=20;i++){
        aa[i]=(i-1)*(aa[i-1]+aa[i-2]);
        //cout<
    }
    int n;
    while(cin>>n)
    {
        int a;
        for(int i=0;i<n;i++){
            cin>>a;
            long long  num=1;
            for(int j=2;j<=a;j++)
                num*=j;
            //cout<
            printf("%.2lf%%\n",(double)aa[a]/num*100.0);//考虑精度是否丢失
        }
    }
    return 0;
}

7/9

2049
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long a[21];
    a[1]=0;a[2]=1;a[3]=2;
    for(int i=4;i<=20;i++){
        a[i]=(i-1)*(a[i-1]+a[i-2]);
    }
    int k;
    while(cin>>k)
    {
        while(k--){
            int n,m;
            cin>>n>>m;
            long long a1=1,a2=1;
            for(int i=n;i>n-m;i--)
                a1*=i;
            for(int i=2;i<=m;i++)
                a2*=i;
            long long int q=a1/a2*a[m];
            cout<<q<<endl;
        }
    }
    return 0;
}

7/10

2050
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long a[10001];
    a[1]=2;
    for(int i=2;i<=10000;i++){
        a[i]=a[i-1]+4*i-3;
    }
    int k;
    while(cin>>k)
    {
        while(k--){
            int q;
            cin>>q;
            cout<<a[q]<<endl;
        }
    }
    return 0;
}
2050
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int k;
    while(cin>>k)
    {
        int a[100];
        int i=0;
        while(k!=0){
            a[i]=k%2;
            i++;
            k=k/2;
        }
        for(i--;i>=0;i--){
            cout<<a[i];
        }
        cout<<endl;
    }
    return 0;
}
2052
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n,m;
    while(cin>>n>>m)
    {
        cout<<"+";
        for(int i=0;i<n;i++)
            cout<<"-";
        cout<<"+"<<endl;;
        for(int j=0;j<m;j++){
            cout<<"|";
            for(int i=0;i<n;i++)
                cout<<" ";
            cout<<"|"<<endl;;
        }
        cout<<"+";
        for(int i=0;i<n;i++)
            cout<<"-";
        cout<<"+"<<endl<<endl;
    }
    return 0;
}
2053
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        double k=sqrt((double)n);
        cout<<(k==(int)k)<<endl;
    }
    return 0;
}
2054
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    char n[100000],m[100000];
    while(cin>>n>>m)
    {
        int a=strlen(n);
        int b=strlen(m);
        if(strchr(n,'.')){
            while(n[a-1]=='0'){
                n[a-1]='\0';
                a--;
            }
            if(n[a-1]=='.') n[a-1]='\0';
        }
        for(int i=0;n[i]=='0';){
                if(n[i+1]=='.'||n[i+1]=='\0')
                    break;
            for(int j=0;n[j]!='\0';j++)
            {
                n[j]=n[j+1];
            }
        }
        if(strchr(m,'.')){
            while(m[b-1]=='0'){
                m[b-1]='\0';
                b--;
            }
            if(m[b-1]=='.') m[b-1]='\0';
        }
        for(int i=0;m[i]=='0'&&m[i+1]!='\0';){
                if(m[i+1]=='.')
                    break;
            for(int j=0;m[j]!='\0';j++)
            {
                m[j]=m[j+1];
            }
        }
        //cout<
        if(strcmp(n,m)==0) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
2055
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    while(cin>>n)
    {
        while(n--){
            char a;
            double b;
            cin>>a>>b;
            if(a>='A'&&a<='Z') cout<<a-'A'+1+b<<endl;
            else cout<<-(a-'a'+1)+b<<endl;
        }
    }
    return 0;
}
2056
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;
void h(double &a1,double &a2,double &b1,double &b2)
{
    if(a1>b1) swap(a1,b1);
    if(a2>b2) swap(a2,b2);
}
int main(void)
{
    double a1,a2,b1,b2,c1,c2,d1,d2;
    while(cin>>a1>>a2>>b1>>b2>>c1>>c2>>d1>>d2)
    {
        h(a1,a2,b1,b2);
        h(c1,c2,d1,d2);
        double area=0;
        if(d1>a1&&d2>a2&&b1>c1&&b2>c2){
            a1=max(a1,c1);
            a2=max(a2,c2);
            b1=min(b1,d1);
            b2=min(b2,d2);
            area=(b1-a1)*(b2-a2);
        }
        printf("%.2f\n",area);
    }
    return 0;
}
2057
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long a, b;
    while((scanf("%I64X %I64X",&a,&b))!=EOF)//用大写的X就AC了
    {
        long long sum=a+b;
        if(sum<0){
            printf("-%I64X\n",-sum);
        }
        else
            printf("%I64X\n",sum);
    }
    return 0;
}

7/11

2058
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n,m;
    while(cin>>n>>m&&n&&m)
    {
        for(int i=sqrt(2.0*m);i>=1;i--){
            int a=(m-(i-1)*i/2)/i;
            if(m==(a*i)+(i-1)*i/2){
                if(a+i-1<=n)
                    cout<<"["<<a<<","<<a+i-1<<"]"<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}
7/12
2059
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int l;
    while(cin>>l)
    {
        int n,c,t;
        cin>>n>>c>>t;
        int  vr,v1,v2;
        cin>>vr>>v1>>v2;
        int a[105]={0};
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        a[n+1]=l;//以上为赋值
        double b[105]={0};
        for(int i=1;i<=n+1;i++){
            b[i]=MAX_INT;
            for(int j=0;j<i;j++){
               double t1;
                int k=a[i]-a[j];
                if(k>=c)  t1=c*1.0/v1+(k-c)*1.0/v2;
                else t1=k*1.0/v1;
                t1+=b[j];
                if(j>0)  t1+=t;
                b[i]=min(t1,b[i]);
            }
        }
        if(b[n+1]<l*1.0/vr) cout<<"What a pity rabbit!"<<endl;
        else cout<<"Good job,rabbit!"<<endl;
    }
    return 0;
}
2060
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int l;
    while(cin>>l)
    {
        while(l--){
            int a,a1,a2;
            cin>>a>>a1>>a2;
            if(a>6){
                a1+=8*a-21;
            }
            else
            {
                int k=7;
                for(int i=0;i<a;i++){
                    a1+=k;
                    k--;
                }
            }
            if(a1>=a2) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}
2061
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int l;
    while(cin>>l)
    {
        while(l--){
            int n;
            cin>>n;
            double x=0,c=0;
            int a60=0;
            for(int i=0;i<n;i++){
                while(getchar()!=' '){}
                double a,b;
                cin>>a>>b;
                if(b<60){
                    a60=1;
                }
                x+=a*b;
                c+=a;
            }
            if(a60) cout<<"Sorry!"<<endl;
            else printf("%.2f\n",x/c);
            if(l!=0) cout<<endl;
        }
    }
    return 0;
}
2062
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long  a[21]={0};
    for(int i=1;i<=20;i++){
        a[i]=(i-1)*a[i-1]+1;
    }
    //cout<
    int n;
    long long m;
    int b[21];
    while(cin>>n>>m)
    {
        for(int i=0;i<21;i++)
            b[i]=i;
        int t;
        while(n>0&&m>0){
            t=m/a[n]+(m%a[n]>0?1:0);
                    cout<<b[t];
                for(int i=t;i<=n;i++)
                    b[i]=b[i+1];
                m=m-((t-1)*a[n])-1;//因为前面有一个空
                if(m==0){
                     cout<<endl;
                     break;
                }
                else cout<<" ";
            n--;
        }
    }
    return 0;
}

7/14

2063
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;
int pei[505][505];
int vis[505],qian[505];//qian[男]=女
int k,m,n;
int a(int x)
{
    for(int i=1;i<=n;i++){
        if(vis[i]==0&&pei[x][i]==1){
            vis[i]=1;
            if(qian[i]==0||a(qian[i])==1){
                qian[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main(void)
{
    while(cin>>k&&k!=0)
    {
        cin>>m>>n;
        memset(pei,0,sizeof(pei));
        memset(qian,0,sizeof(qian));
        for(int i=0;i<k;i++){
            int a,b;
            cin>>a>>b;
            pei[a][b]=1;
        }
        int ans=0;
        for(int i=1;i<=m;i++){
            memset(vis,0,sizeof(vis));
            if(a(i)) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

7/15

6297
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
   int n;
   cin>>n;
   while(n--)
   {
        int a;
        cin>>a;
        if(a<10)
            cout<<"  ";
        else if(a<100)
            cout<<" ";
        cout<<a<<"|";
        char b[16];
        //memset(b,' ',sizeof(b));
        cin>>b;
        cout<<b;
        for(int i=0;i<16-strlen(b);i++)
            cout<<" ";
        int c;
        cin>>c;
        cout<<"|"<<c<<"|[";
        char d[7];
        cin>>d;
        if(!strcmp(d,"Running")){
            int e;
            cin>>e;
            for(int i=0;i<e;i++)
                cout<<"X";
            for(int i=0;i<10-e;i++)
                cout<<" ";
        }
        else{
            if(!strcmp(d,"FB"))
                strcpy(d,"AC*");
            cout<<"    "<<d;
            for(int i=0;i<6-strlen(d);i++)
                cout<<" ";
        }
        cout<<"]"<<endl;
   }
    return 0;
}
2064
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    long long a[36]={0,2};
    for(int i=2;i<=35;i++){
        a[i]=3*a[i-1]+2;
    }
   int n;
   while(cin>>n)
   {
        cout<<a[n]<<endl;
   }
    return 0;
}

7/16/19

2065
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int a[24]={0,2};
    int num=1,num1=1;
    for(int i=2;i<24;i++){
        num*=2;
        num1*=4;
        num%=100;
        num1%=100;
        //cout<
        a[i]=(num+num1)%100;
    }
   long long int n;
   while(cin>>n&&n!=0)
   {
        long long i=1;
        while(n--){
            long long int k;
            cin>>k;
            if(k>2)
                k=(k-3)%20+3;
            cout<<"Case "<<i<<": ";
            i++;
            cout<<a[k]<<endl;
        }
        cout<<endl;
   }
    return 0;
}
2018CCPC吉林赛区   2
未知
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
using namespace std;

int main(void)
{
    int n;
    int a;
    char b;
    int c;
    char d[2];
    char s1[10],s2[10];
    int i=1;
    while(cin>>n){
        while(n--){
            cin>>a>>b>>c>>d>>s1>>s2;
            if(!strcmp("AM",d)){
                if(a==12) a=0;
            }
            if(!strcmp("PM",d)){
                a+=12;
            }
            int k1,k2;
            if(!strcmp("Beijing",s1))
                k1=8;
            if(!strcmp("Washington",s1))
                k1=-5;
            if(!strcmp("London",s1))
                k1=0;
            if(!strcmp("Moscow",s1))
                k1=3;
            if(!strcmp("Beijing",s2))
                k2=8;
            if(!strcmp("Washington",s2))
                k2=-5;
            if(!strcmp("London",s2))
                k2=0;
            if(!strcmp("Moscow",s2))
                k2=3;
            a=a-k1+k2;
            cout<<"Case "<<i++<<": ";
            char ss[10];
            if(a>=24){
                a-=24;
                strcpy(ss,"Tomorrow");
            }
            else if(a<0){
                a+=24;
                strcpy(ss,"Yesterday");
            }
            else
                strcpy(ss,"Today");
            if(a==12){
                strcpy(d,"PM");
            }
            else if(a>12){
                a-=12;
                strcpy(d,"PM");
            }
            else
                strcpy(d,"AM");
            if(a==0){
                a=12;
            }
            cout<<ss<<" "<<a<<":";
            if(c==0) cout<<0;
            cout<<c<<" "<<d<<endl;
        }
    }
    return 0;
}
1231
#include 
#include 
#include 
#include"stdio.h"
#include 
#include
//#include
#define MAX_INT ((unsigned)(-1)>>1)
#define MIN_INT (~MAX_INT)
#define pi 3.1415926535898
using namespace std;
int a[10005];
int main(void)
{
      int n;
      while(cin>>n){
                  int tt=0;
            for(int i=0;i<n;i++){
                  cin>>a[i];
                  if(a[i]>=0)
                        tt=1;
            }
            int l=0,l1=0,r=0,max1=-1 ,r1=0;
            int num=0;
            for(int i=0;i<n;i++){
                  num+=a[i];
                  if(num<=0){
                        num=0;
                        l=i+1;
                  }
                  if(num>max1){
                        max1=num;
                        l1=l;
                        r1=i;
                        if(max1==0)
                              r1=l;
                  }
            }
            if(max1==0&&!tt) l1=0,r1=n-1;
            if(n==0) max1=a[l1]=a[r1]=0;
            else cout<<max1<<" "<<a[l1]<<" "<<a[r1]<<endl;
      }
      return 0;
}

2019/11/13

2066
一个人的旅行
虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假,可是也不能荒废了训练啊,所以草儿决定在要在最短的时间去一个自己想去的地方!因为草儿的家在一个小镇上,没有火车经过,所以她只能去邻近的城市坐火车(好可怜啊~)。
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
int a[1005][1005];
int b[1005],c[1005];
int main(void)
{
    int t,s,d;
    while(cin>>t>>s>>d){
        int n=0;
        for(int i=0;i<=1000;i++)
        {
            for(int j=0;j<=1000;j++)
            {
                if(i==j) a[i][j]=0;
                else a[i][j]=INF;
            }
        }
        memset(b,0,sizeof b);
        memset(c,0,sizeof c);
        int a1,a2,a3;
        while(t--){
            cin>>a1>>a2>>a3;
            n=max(n,max(a1,a2));
            a[a1][a2]=a[a2][a1]=min(a[a1][a2],a3);
        }
        for(int i=1;i<=s;i++) cin>>a1,b[i]=a1;
        for(int i=1;i<=d;i++) cin>>a1,c[i]=a1;
        for(int k=1;k<=n;k++){
            for(int i=1;i<=n;i++){
                if(a[k][i]==INF) continue;
                for(int j=1;j<=n;j++){
                    if(i==j) continue;
                    a[i][j]=a[j][i]=min(a[i][j],a[i][k]+a[k][j]);
                    //cout<
                }
            }
        }
        int ans=INF;
        for(int i=1;i<=s;i++){
            for(int j=1;j<=d;j++){
                ans=min(a[b[i]][c[j]],ans);
                //cout<
            }
        }
        cout<<ans<<endl;
     }
    return 0;
}

2067
小兔的棋盘
小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(00)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不难吧!
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
ll a[40][40];
int main(void)
{
    for(int i=0;i<=35;i++) a[i][0]=1;
    for(int i=0;i<=35;i++){
        for(int j=1;j<=35;j++){
            if(i<j) continue;
            if(i==j) a[i][j]=a[i][j-1];
            else a[i][j]=a[i-1][j]+a[i][j-1];
        }
    }
    int n;
    int num=1;
    while(cin>>n){
        if(n==-1) break;
        cout<<num++<<" "<<n<<" "<<2*a[n][n]<<endl;
    }
    return 0;
}

2019/11/14
2068
RPG的错排
今年暑假杭电ACM集训队第一次组成女生队,其中有一队叫RPG,但做为集训队成员之一的野骆驼竟然不知道RPG三个人具体是谁谁。RPG给他机会让他猜猜,第一次猜:R是公主,P是草儿,G是月野兔;第二次猜:R是草儿,P是月野兔,G是公主;第三次猜:R是草儿,P是公主,G是月野兔;......可怜的野骆驼第六次终于把RPG分清楚了。由于RPG的带动,做ACM的女生越来越多,我们的野骆驼想都知道她们,可现在有N多人,他要猜的次数可就多了,为了不为难野骆驼,女生们只要求他答对一半或以上就算过关,请问有多少组答案能使他顺利过关。
解题思路:先从猜对的女生个数出发,有[n/2,n]种情况,猜对i个时在n个女生中找出i个女生,为猜对了的女生。再将剩下n-i个女生错排。所以此题就是求1~n/2每项的错排数再乘以组合数(函数c(n,m)求组合数)之和。
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
ll a[15];
ll num(int n,int m)
{
    ll ans=1;
    for(int i=1;i<=m;i++){
        ans=ans*(n+1-i)/i;
    }//求组合数
    return ans;
}
int main(void)
{
    a[1]=0,a[2]=1;
    for(ll i=3;i<=13;i++) a[i]=(i-1)*(a[i-1]+a[i-2]);
    int n;
    while(cin>>n&&n){
        int m=n/2;
        ll ans=1;
        for(int i=2;i<=m;i++){
            ans+=num(n,i)*a[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

2069
硬币兑换
假设有5种硬币:50美分、25美分、10美分、5美分和1美分。我们想用这些硬币兑换一定数量的钱。
例如,如果我们有11美分,那么我们可以用一枚10美分硬币和一枚1美分硬币,或者两枚5美分硬币和一枚1美分硬币,或者一枚5美分硬币和六枚1美分硬币,或者十一枚1美分硬币进行兑换。所以有四种方法可以用上面的硬币兑换11美分。请注意,我们认为有一种方法可以改变零美分。
编写一个程序,找出以美分为单位改变任何金额的不同方法的总数。你的程序应该能处理多达100枚硬币。
动态规划:用i个硬币可以组成j块钱的有多少种
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
ll a[105][255];//a[i][j] 用i个硬币可以组成j块钱的有多少种
int m[]={1,5,10,25,50};
int main(void)
{
    a[0][0]=1;
    for(int k=0;k<5;k++){
        for(int i=1;i<=100;i++){
            for(int j=250;j>=m[k];j--){
                a[i][j]+=a[i-1][j-m[k]];
            }
        }
    }
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0;i<=100;i++){
            ans+=a[i][n];
        }
        cout<<ans<<endl;
    }
    return 0;
}

2070
Fibbonacci Number
Your objective for this question is to develop a program which will generate a fibbonacci number. The fibbonacci function is defined as such:
f(0) = 0
f(1) = 1
f(n) = f(n-1) + f(n-2)
Your program should be able to handle values of n in the range 0 to 50.
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
ll a[55];
int main(void)
{
    a[0]=0,a[1]=1;
    for(int i=2;i<=50;i++){
        a[i]=a[i-1]+a[i-2];
    }
    int n;
    while(cin>>n){
        if(n==-1) break;
        cout<<a[n]<<endl;
    }
    return 0;
}

2072
单词数
lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数。下面你的任务是帮助xiaoou333解决这个问题。
有多组数据,每组一行,每组就是一篇小文章。每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束。
每组只输出一个整数,其单独成行,该整数代表一篇文章里不同单词的总数。
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define INF MAX_INT/2
using namespace std;
char b[200][200];
int main(void)
{
    char s[999999];
    while(gets(s)){
        if(strcmp(s,"#")==0) break;
        int l=strlen(s);
        int i=0;
        int g=0,h=0;
        while(i<l){
            if(s[i]==' ') i++;
            else{
                for(;s[i]!=' '&&s[i]!='\0';i++,h++){
                    b[g][h]=s[i];
                }
                b[g][h]='\0';
                g++;
                h=0;
            }
        }
        int ans=0;
        for(int j=0;j<g;j++){//对每一个单词进行寻找,找到相同的就不加上去
            int temp=1;
            for(int k=0;k<j;k++){
                if(strcmp(b[j],b[k])==0) temp=0;
            }
            if(temp) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

2073
无限的路
甜甜从小就喜欢画图画,最近他买了一支智能画笔,由于刚刚接触,所以甜甜只会用它来画直线,于是他就在平面直角坐标系中画出如下的图形:

甜甜的好朋友蜜蜜发现上面的图还是有点规则的,于是他问甜甜:在你画的图中,我给你两个点,请你算一算连接两点的折线长度(即沿折线走的路线长度)吧。
一个一个个记录下到0 0的距离,然后需要的减一下就行。
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define mod 1000000007
#define inf 0x3f3f3f3f
#define maxx 200005
using namespace std;
double a[205][205];
double sd(double x1,double y1,double x2,double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(void)
{
    int ii=0,jj=0;
    for(int i=0;i<=200;i++){
        for(int j=0;j<=i;j++){
            if(i==0&&j==0) a[i][j]=0;
            else{
                a[j][i-j]=a[ii][jj]+sd(ii,jj,j,i-j);
                ii=j,jj=i-j;
            }
        }
    }
    int t;
    int a1,a2,a3,a4;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&a1,&a2,&a3,&a4);
        printf("%.3f\n",abs((a[a1][a2])-(a[a3][a4])));
    }
    return 0;
}

2074	 叠筐
需要的时候,就把一个个大小差一圈的筐叠上去,使得从上往下看时,边筐花色交错。这个工作现在要让计算机来完成,得看你的了。
 
Input
输入是一个个的三元组,分别是,外筐尺寸n(n为满足0<n<80的奇整数),中心花色字符,外筐花色字符,后二者都为ASCII可见字符;
 
Output
输出叠在一起的筐图案,中心花色与外筐花色字符从内层起交错相叠,多筐相叠时,最外筐的角总是被打磨掉。叠筐与叠筐之间应有一行间隔。
 
Sample Input
11 B A
5 @ W
 
Sample Output
 AAAAAAAAA 
ABBBBBBBBBA
ABAAAAAAABA
ABABBBBBABA
ABABAAABABA
ABABABABABA
ABABAAABABA
ABABBBBBABA
ABAAAAAAABA
ABBBBBBBBBA
 AAAAAAAAA 

 @@@ 
@WWW@
@W@W@
@WWW@
 @@@ 

注意输出n==1的时候要特判。
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
map<char,vector<int> > p ;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
char q[85][85];
char a[3];
int main(void)
{
    int n;
    int temp=0;
    while(cin>>n>>a[1]>>a[0]){
        if(!temp) temp=1;
        else cout<<endl;
        if(n==1){
            cout<<a[1]<<endl;
            continue;
        }
        if((n+1)/2%2==0) swap(a[1],a[0]);
        for(int i=1;i<=n/2+1;i++){
            for(int j=i;j<=n-i+1;j++){
                q[j][i]=q[i][j]=a[i%2];
                q[j][n+1-i]=q[n+1-i][j]=a[i%2];
            }
        }
        q[n][1]=q[1][n]=q[1][1]=q[n][n]=' ';
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                cout<<q[i][j];
            }
            cout<<endl;
        }
    }
    return 0;
}

2077 汉诺塔IV
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 3.1415926535898
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
map<char,vector<int> > p ;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

ll a[21]={0,2};
int main(void)
{

    for(int i=1;i<=20;i++)
        a[i]=a[i-1]*3+2;
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        if(n==1) cout<<2<<endl;
        else cout<<a[n-1]+2<<endl;
    }
    return 0;
}

2078	 复习时间
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 4*atan(1.0)
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
//不一定复习m门功课,只求最大效率。
//就是用100减去最小数的平方。
int main(void)
{
    int t;cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        int k=100;
        for(int i=1;i<=n;i++){
            int a;cin>>a;
            k=min(a,k);
        }
        cout<<(100-k)*(100-k)<<endl;
    }

    return 0;
}

2079	 选课时间
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi 4*atan(1.0)
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int n,k,ans=0;
int a[9][2];
void dfs(int i1,int num)
{
    if(num==n){ans++;return;}
    if(num>n||i1>=k) return ;
    for(int i=0;i<=a[i1][1];i++){
        dfs(i1+1,num+i*a[i1][0]);
    }
}
int main(void)
{
    int t;cin>>t;
    while(t--){
        cin>>n>>k;
        memset(a,0,sizeof a);
        for(int i=0;i<k;i++){
            cin>>a[i][0]>>a[i][1];
        }
        ans=0;
        dfs(0,0);
        cout<<ans<<endl;
    }
    return 0;
}

2080	 夹角有多大II
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

int main(void)
{
    //cout<
    int t;cin>>t;
    while(t--){
        double a[5];
        cin>>a[1]>>a[2]>>a[3]>>a[4];
        printf("%.2f\n",abs(atan2(a[1],a[2])/pi*180-atan2(a[3],a[4])/pi*180));
    }
    return 0;
}

2081	 手机短号
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

int main(void)
{
    int t;cin>>t;
    while(t--){
        ll k;cin>>k;
        cout<<600000+k%100000<<endl;
    }
    return 0;
}

2082	 找单词
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int a[27];
ll dp[27][51];
int main(void)
{
    int t;cin>>t;
    while(t--){
        for(int i=1;i<=26;i++){
            cin>>a[i];
        }
        memset(dp,0,sizeof dp);
        dp[0][0]=1;
        for(int i=1;i<=26;i++){
            for(int j=0;j<=a[i];j++){
                for(int k=0;k<=50;k++){
                    if(k+i*j<=50){
                        dp[i][k+i*j]+=dp[i-1][k];
                    }
                }
            }
        }
        int num=0;
        for(int i=1;i<=50;i++){
            //cout<
            num+=dp[26][i];
        }
        cout<<num<<endl;
    }
    return 0;
}

2083	 简易版之最短距离
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int a[505];
int main(void)
{
    int t;cin>>t;
    while(t--){
        int k;cin>>k;
        int num=0;
        for(int i=1;i<=k;i++){
            cin>>a[i];
        }
        sort(a+1,a+1+k);
        for(int i=1;i<=k/2;i++){
            num+=a[k-i+1]-a[i];
        }
        cout<< num <<endl;
    }
    return 0;
}

2084	 数塔
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int a[105][105];
int main(void)
{
    int t;cin>>t;
    //for(int i=0;i<=105;i++) a[i][0]=a[i][i+1]=inf;
    while(t--){
        int k;cin>>k;
        for(int i=1;i<=k;i++){
            for(int j=1;j<=i;j++){
                cin>>a[i][j];
            }
        }
        for(int i=2;i<=k;i++){
            for(int j=1;j<=i;j++){
                a[i][j]+=max(a[i-1][j],a[i-1][j-1]);
            }
        }
        int ans=0;
        for(int i=1;i<=k;i++) ans=max(ans,a[k][i]);
        cout<<ans<<endl;
    }
    return 0;
}

2085	 核反应堆
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
ll a[40][2];
int main(void)
{
    a[0][0]=1;
    for(int i=1;i<=33;i++){
        a[i][0]=a[i-1][0]*3+a[i-1][1]*2;
        a[i][1]=a[i-1][0]+a[i-1][1];
    }
    int t;
    while(cin>>t){
        if(t==-1) break;
        cout<<a[t][0]<<", "<<a[t][1]<<endl;
    }
    return 0;
}

2086	 A1 = ?
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
double c[3005];
int main(void)
{
    int t;
    while(cin>>t){
        double a1,an;cin>>a1>>an;
        c[0]=0;
        for(int i=1;i<=t;i++) cin>>c[i],c[i]+=c[i-1];
        double num=0;
        for(int i=1;i<=t;i++){
            num+=c[i];
        }
        printf("%.2f\n",(an+a1*t-2*num)/(t+1));
    }
    return 0;
}

2087	 剪花布条
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

int main(void)
{
    string t;
    while(cin>>t){
        if(t=="#") break;
        string k;cin>>k;
        int num=0;
        int len=k.length();
        for(int i=0;i<t.length();i++){
            if(t.substr(i,len)==k){
                num++;
                i+=len-1;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}

2088	 Box of Bricks
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int a[55];
int main(void)
{
    int t;
    int temp=0;
    while(cin>>t){
        if(t==0) break;
        if(temp) cout<<endl;
        temp=1;
        int num=0;
        for(int i=1;i<=t;i++){
            cin>>a[i];
            num+=a[i];
        }
        num/=t;
        int ans=0;
        for(int i=1;i<=t;i++){
            if(a[i]>num) ans+=a[i]-num;
        }
        cout<<ans<<endl;
    }
    return 0;
}

2089	 不要62
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int a[1000005];
int main(void)
{
    a[0]=0;
    for(int i=1;i<1000000;i++){
        int temp=1;
        int k=i;
        while(k){
            if(k%10==4||k%100==62){
                temp=0;
            }
            k/=10;
        }
        if(temp) a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    int a1,a2;
    while(cin>>a1>>a2){
        if(a1==0&&a2==0) break;
        cout<<a[a2]-a[a1-1]<<endl;
    }
    return 0;
}

 	2090	 算菜价
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

int main(void)
{
    string s;double a,b,num=0;
    while(cin>>s>>a>>b){
        num+=a*b;
    }
    printf("%.1f\n",num);
    return 0;
}

2092	 整数解
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
bool pan(int a,int b)
{
    for(int i=-10000;i<=10000;i++){
        if((a-i)*i==b) return 1;
    }
    return 0;
}
int main(void)
{
    int a,b;
    while(cin>>a>>b){
        if(a||b) if(pan(a,b)) cout<<"Yes"<<endl;else cout<<"No"<<endl;
        else break;
    }
    return 0;
}

2093	 考试排名
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
struct node
{
    string name;
    int ac;
    int num;
}a[100005];
bool cmp(node a,node b)
{
    if(a.ac==b.ac&&a.num==b.num) return a.name<b.name;
    if(a.ac==b.ac) return a.num<b.num;
    return a.ac>b.ac;
}
int main(void)
{
    int n,m;cin>>n>>m;
    int t=0;
    while(cin>>a[t].name){
        int p,q;
        a[t].num=0;
        for(int i=1;i<=n;i++){
            cin>>p;
            if(p>0){
                a[t].ac++;
                if(getchar()=='('){
                    cin>>q;
                    a[t].num+=(m*q+p);
                    getchar();
                }
                else a[t].num+=p;
            }
        }
        t++;
    }
    sort(a,a+t,cmp);
    for(int i=0;i<t;i++){
        cout<<a[i].name;
        int len=a[i].name.length();
        for(int j=0;j<(10-len);j++){
            cout<<" ";
        }
        printf(" %2d",a[i].ac);
        printf(" %4d\n",a[i].num);
    }
    return 0;
}

2094	 产生冠军
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}
int max1=10000;
int main(void)
{
    int n;
    while(cin>>n){
        if(!n) break;
        map<string,int> m;
        string a,b;
        while(n--){
            cin>>a>>b;
            m[a]++;
            m[b]=max1;
        }
        int ans=0;
        map<string,int>::iterator it;
        for(it=m.begin();it!=m.end();it++){
            if((it->second)<max1) ans++;
        }
        if(ans==1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

2095	 find your present (2)
#include
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define pi (4*atan(1.0))
#define ll long long
#define inf 0x3f3f3f3f
#define infmax 0x3f3f3f3f3f3f3f3f
using namespace std;
int read()
{
    int c=0;int flag=1;
    char s;
    while((s=getchar())>'9'||s<'0')if(s=='-')flag=-1;
    c=s-'0';
    while((s=getchar())<='9'&&s>='0') c=c*10+s-'0';
    return c*flag;
}

int main(void)
{
    int n;
    while(cin>>n){
        if(!n) break;
        int t=0;
        int k;
        while(n--){
            k=read();
            t^=k;
        }
        cout<<t<<endl;
    }
    return 0;
}

你可能感兴趣的:(杭电oj2000开始的100道部分代码)