Skip to content

写程序得女朋友?(笑

昨天很多人都在玩,我于是也试了一下……
屏幕快照 2015-12-10 上午12.23.00
https://paiza.jp/poh/ando
花了一个半小时,心累。
放一下最后三道题吧:

眼镜:

#include <iostream>
#include <vector>

using namespace std;

vector< vector<int> > surface1;
vector< vector<int> > surface2;
int x_final, y_final;

void find(int size1, int size2)
{
    for (int i = 0; i < size1 - size2 + 1; ++i)
        for (int j = 0; j < size1 - size2 + 1; ++j)
        {
            bool flag = true;
            for (int x = 0; x < size2; ++x)
            {
                for (int y = 0; y < size2; ++y)
                    if (surface2[x][y] != surface1[i + x][j + y])
                    {
                        flag = false;
                        break;
                    }
                if (!flag)
                    break;
            }
            if (flag)
            {
                x_final = i; y_final = j;
                return;
            }
        }
}

int main()
{
    int size1, size2;
    cin >> size1;
    surface1.resize(size1);
    for (int i = 0; i < size1; ++i)
        for (int j = 0; j < size1; ++j)
        {
            int temp;
            cin >> temp;
            surface1[i].push_back(temp);
        }
    cin >> size2;
    surface2.resize(size2);
    for (int i = 0; i < size2; ++i)
        for (int j = 0; j < size2; ++j)
        {
            int temp;
            cin >> temp;
            surface2[i].push_back(temp);
        }
    find(size1, size2);
    cout << x_final << " " << y_final << endl;
    return 0;
}

圣诞服:

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> side;
vector<int> front;
int X, Y, Z;
int minX, minY, minZ;

void slice(int status, int position)
{
    if (status == 1)
    {
        for (vector<int>::iterator it = side.begin(); it != side.end() - 1; ++it)
            if (*it < position && *(it + 1) > position)
                minY = min(position - *it, *(it + 1) - position);
        side.push_back(position);
        sort(side.begin(), side.end());
    }
    else
    {
        for (vector<int>::iterator it = front.begin(); it != front.end() - 1; ++it)
            if (*it < position && *(it + 1) > position)
                minX = min(position - *it, *(it + 1) - position);
        front.push_back(position);
        sort(front.begin(), front.end());
    }
    return ;
}

int main()
{
    int times;
    cin >> X >> Y >> Z >> times;
    minX = X; minY = Y; minZ = Z;
    front.push_back(0);
    front.push_back(X);
    side.push_back(0);
    side.push_back(Y);
    for (int i = 0; i < times; ++i)
    {
        int status, position;
        cin >> status >> position;
        slice(status, position);
    }
    cout << minX * minY * minZ << endl;
}

泳衣:

#include <iostream>

using namespace std;

typedef long long LL;

LL process(LL input)
{
    while (input % 10 == 0)
        input /= 10;
    return input % 1000000000000;
}

LL fact(int need)
{
    LL ans = 1;
    for (int i = 2; i <= need; ++i)
    {
        ans *= i;
        ans = process(ans);
    }
    return ans;
}

int main()
{
    int need;
    cin >> need;
    cout << fact(need) % 1000000000 << endl;
}

女朋友真的能这样吗(◎-◎;)

Published in我的程序

One Comment

发表评论

邮箱地址不会被公开。 必填项已用*标注