zoj 5道水题 2818 3323,3333,3479,3486

#include<iostream>//2818
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int B,N,A;
	int i,j,sum=1,temp;
	while(~scanf("%d%d",&B,&N))
	{
		if(B==0&&N==0) break;
		for(i=1;i<1000005;i++)
		{	
			temp=sum;
			sum=1;
			for(j=0;j<N;j++)
				sum*=i;
			if(sum>=B)
			{
				if(fabs(B-temp)>=fabs(B-sum)) A=i;
				else A=i-1;
				break;
			}
		}
		cout<<A<<endl;
	}
	return 0;
}


#include<cstdio>//zoj3323 Somali Pirates 
#include <string.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
int n,len,i,j;
char a[25],b[25];
cin>>n;
while(n--)
{
cin>>a;
len=strlen(a);
for(i=0,j=0;i<len;i++)
{
if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z')
b[j++]=a[i];
}
b[j]='\0';
cout<<b<<endl;
}
return 0;
}
#include <iostream>//zoj3333 Guess the Price 
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
    int T;
    cin>>T;
    while (T--)
    {
        int a,b,c;
        string d;
        cin>>a>>b>>c;
        if(fabs(a-b)>fabs(a-c)) d="B";
        else d="A";
        cout<<d<<endl;
    }
    return 0;
}
#include<cstdio>//zoj3479 Chinese Zodiac 
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int N,year;
    cin>>N;
    char a[12][22]={"Rabbit", "Tiger","Ox","Rat", "Pig", "Dog", "Rooster", "Monkey", "Ram", "Horse", "Snake","Dragon"};
    while(N--)
    {
        cin>>year;
        if(year%12==0) cout<<a[11]<<endl;
        else
        cout<<a[year%12-1]<<endl;
    }
}
#include<iostream>//zoj 3486Judge Internal Error 
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,j,a[1005],b[10005],temp;
    cin>>n;
    while(n--)
    {
        cin>>m;
        memset(b,0,sizeof(b));
        for(i=0;i<m;i++)
        {
            cin>>a[i];
            b[a[i]]++;
        }
        for(i=0;i<m;i++)
        {
            for(j=i;j<m;j++)
            {
                if(b[a[i]]<b[a[j]])
                {
                    temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
                if(b[a[i]]==b[a[j]]) 
                {
                    if(a[i]<a[j])
                    {
                        temp=a[i];
                        a[i]=a[j];
                        a[j]=temp;
                    }
                }
            }
        }
        cout<<a[0]<<endl;
    }
    return 0;
}



你可能感兴趣的:(c,String,pig)