【标程】山东建筑大学第一届ACM程序设计竞赛(2013.12.1)题解

Problem A Paparizzi:

#include <fstream>
#include <iostream>
using namespace std;

string bef="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
string tra="wertyuiopqsdfghjklaxcvbnmzWERTYUIOPQSDFGHJKLAXCVBNMZ";

int main()
{
	//ofstream cout;
	//ifstream cin;
	//cin.open("A_ALL.in");
	//cout.open("A_ALL.out");
	int testcase;
	cin>>testcase;
	while(testcase--)
	{
		string tar,end;
		cin>>tar;
		for(int i=0;i<tar.length();i++)
		{
			for(int j=0;j<bef.length();j++)
			{
				if(bef[j]==tar[i])
					end+=tra[j];
			}
		}
		cout<<end<<endl;
	}
	
	return 0;
}
Problem B 一千年以后:

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <fstream>
using namespace std;

int luna[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int un_luna[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

bool is_luna(int year)
{
    if((year%4==0 && year%100!=0)||(year%400==0))
        return 1;
    else
        return 0;
}

int main()
{
    int year,month,day;
    /*ifstream cin;
    ofstream cout;
    cin.open("2.in");
    cout.open("2.out");*/
    
    while(cin>>year>>month>>day)
    {
        int total=0;
        if(is_luna(year))
        {
            for(int i=1;i<month;i++)
            {
                total+=luna[i];
            }
            total+=day;
        }
        else
        {
            for(int i=1;i<month;i++)
            {
                total+=un_luna[i];
            }
            total+=day;
        }
        cout<<total<<endl;
    }
    return 0;
}

Problem C 蒲公英的约定:

#include <fstream>
#include <iostream>

using namespace std;
int main()
{
    int n;
    int a,b;
   /* ifstream cin;
    ofstream cout;
    cin.open("3.in");
    cout.open("3.out");*/
    
    cin>>n;
    while(n--)
    {
        cin>>a>>b;
        if(a%b==0)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
    return 0;
}

Problem D 千百度

#include <iostream>
#include <fstream>
using namespace std;


int istri(int a,int b,int c)
{
    int big,other1,other2;
    if(a>b && a>c)
    {
        big=a;
        other1=b;
        other2=c;
    }
    else if(b>c && b>a)
    {
        big=b;
        other1=a;
        other2=c;
    }
    else if(c>a && c>b)
    {
        big=c;
        other1=a;
        other2=b;
    }
    else
        return false;
    if((other1*other1)+(other2*other2)==big*big)
        return true;
    else
        return false;
    
}

int main()
{
    int testcase;
   /* ifstream cin;
    ofstream cout;
    cin.open("D_ALL.in");
    cout.open("D_ALL.out");*/
    cin>>testcase;
    for(int i=1;i<=testcase;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(istri(a,b,c))
        {
            cout<<"Scenario #"<<i<<":"<<endl;
            cout<<"yes"<<endl;
        }
        else
        {
            cout<<"Scenario #"<<i<<":"<<endl;
            cout<<"no"<<endl;
        }
    }
    return 0;
}
Problem E 红尘客栈(标程暂缺)

Problem F 发如雪

#include <iostream>
#include <cstring>
#include <fstream>

using namespace std;

char mat[115][115];
int visited[115][115];

void dfs(int x,int y)
{
    if((visited[x][y]==1 || mat[x][y]=='*' ))
        return;
    visited[x][y]=1;
    dfs(x-1,y-1);
    dfs(x-1,y);
    dfs(x-1,y+1);
    
    dfs(x,y-1);
    dfs(x,y+1);
    
    dfs(x+1,y-1);
    dfs(x+1,y);
    dfs(x+1,y+1);
}

int main()
{
	/*ifstream cin;
	cin.open("5.in");
	ofstream cout;
	cout.open("5.out");*/
	int length,height;
	int testcase;
	cin>>testcase;
	while(testcase--)
    {
    	cin>>length>>height;
        
        memset(mat,'*',sizeof(mat));
        memset(visited,0,sizeof(visited));
        int count=0;
        for(int i=1;i<=length;i++)
        {
            for(int j=1;j<=height;j++)
            {
                cin>>mat[i][j];
            }
        }
        
        for(int i=1;i<=length;i++)
        {
            for(int j=1;j<=height;j++)
            {
                if(mat[i][j]=='@' && visited[i][j]==0)
                {
                    dfs(i,j);
                    count++;
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}

Problem G When you're gone 标程暂缺

Problem H 雨花石 标程暂缺

Problem I 义勇军进行曲

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

int T;

struct Point
{
	int x, y;
};

struct Square
{
	Point a1, a2, a3, a4;
};

Square s;

int main()
{
	/*ifstream cin;
	ofstream cout;
	cin.open("G_ALL.in");
	cout.open("G_ALL.out"); */
	cin>>T;

	while(T--)
	{
		cin>>s.a1.x>>s.a1.y>>s.a2.x>>s.a2.y>>s.a3.x>>s.a3.y>>s.a4.x>>s.a4.y;

		int dis1=((s.a2.x-s.a1.x)*(s.a2.x-s.a1.x)+(s.a2.y-s.a1.y)*(s.a2.y-s.a1.y));
		int dis2=((s.a3.x-s.a2.x)*(s.a3.x-s.a2.x)+(s.a3.y-s.a2.y)*(s.a3.y-s.a2.y));
		int dis3=((s.a4.x-s.a3.x)*(s.a4.x-s.a3.x)+(s.a4.y-s.a3.y)*(s.a4.y-s.a3.y));
		int dis4=((s.a1.x-s.a4.x)*(s.a1.x-s.a4.x)+(s.a1.y-s.a4.y)*(s.a1.y-s.a4.y));

		int dis=((s.a3.x-s.a1.x)*(s.a3.x-s.a1.x)+(s.a3.y-s.a1.y)*(s.a3.y-s.a1.y));
		

		if(dis == (dis1 + dis2) && dis1 == dis2 && dis2 == dis3 && dis3 == dis4 && dis4 == dis1)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}

Problem J 致青春:送分题,直接输出那一句话就行了。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值