爱奇艺 秋招 测试开发工程师 笔试 1题AC+2题思路

第一题:
切割块,大意是x y z的立方体,切k刀,只能整点坐标切割
思路:平均切,一面一刀,开longlong
写的很繁琐 233333
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
      int x,y,z;
      int k;
      int xx,yy,zz;
      long long ans;

      scanf("%d%d%d%d",&x,&y,&z,&k);

      xx=1;yy=1;zz=1;
      int step;
      step=1;
      for (int t=1;t<=k;t++)
      {
            if (xx==x && yy==y && zz==z) break;

            if (step==1)
            {
                  if (xx<x)
                  {
                        xx++;
                        step=2;
                  }
                  else if (yy<y)
                  {
                        yy++;
                        step=3;
                  }
                  else if (zz<z)
                  {
                        zz++;
                        step=1;
                  }
            }
            else if (step==2)
            {
                  if (yy<y)
                  {
                        yy++;
                        step=3;
                  }
                  else if (zz<z)
                  {
                        zz++;
                        step=1;
                  }
                  else if (xx<x)
                  {
                        xx++;
                        step=2;
                  }
            }
            else if (step==3)
            {
                  if (zz<z)
                  {
                        zz++;
                        step=1;
                  }
                  else if (xx<x)
                  {
                        xx++;
                        step=2;
                  }
                  else if (yy<y)
                  {
                        yy++;
                        step=3;
                  }
            }
      }
      ans=xx*yy;
      ans=ans*zz;
      printf("%lld\n",ans);

      return 0;
}

第二题不会
给定长度为N-1的01序列A,P为1~N的数列
求满足:A[i]=0时P[i]<P[i+1],A[i]=1时P[i]>P[i+1] 的P的排列的方案数

暴搜剪不剪枝都18%...直接输样例也18%,写到自闭,是我配不上爱奇艺!
然后我去问巨佬第二题思路了
f[i][j]表示我们处理到了第i位,第i位的数字,在接下来的m=(n-i+1)个数(包括第i个位置)中排第j的方案数
a[i]==0:此时有m-j个数可以放在下一个位置,可以更新的是f[i+1] [j ~ m-j] ,就是在j~m中找比当前j大的数来更新,这一段的数,要+=f[i][j]
a[i]==1:此时有j-1个数可以放在下一个位置,可以更新f[i+1][1 ~ j]


#爱奇艺##笔试题目#
全部评论
import copy a = input() array = list(map(int,raw_input().split())) empty_list = [] empty_list1 = [] count = 0 def full_arrange(n):     data = []     res = []     if n==1:         return 1     res = [[1]]     for i in range(2,n+1):         for j in range(len(res)):             for x in range(len(res[j])+1):                 data = copy.copy(res[j])                 data.insert(x,i)                 res.append(data)                 x += 1             j += 1         while True:             if len(res[0]) != i:                 res.remove(res[0])             else:                 break         i += 1     return res #print(full_arrange(3)) possible = full_arrange(a) def solution(x):     for i in range(len(x)-1):         if x[i] > x[i+1]:             m = 1             empty_list.append(m)         if x[i] <x[i+1]:             m = 0             empty_list.append(m)     return (empty_list) for i in possible:     empty_list1.append(solution(i)) print(empty_list1) for i in range(len(empty_list1)):     if array == empty_list1[i]:         count = count+1 print(count) 第二题答案,每次都是马后炮,因为一个小细节没通过,考完了五分钟就解决了😣
点赞 回复 分享
发布于 2019-09-08 17:20
哈哈爆搜剪枝我36 leetcode903 原题 没刷到那么远
点赞 回复 分享
发布于 2019-09-08 17:07
第一题可以解释一下思路吗?
点赞 回复 分享
发布于 2019-09-08 17:13
第一题为什么每步切x y z的顺序要不一样呢
点赞 回复 分享
发布于 2019-09-08 17:17
from functools import lru_***  N=int(input()) S=input().split(' ')  MOD = 10**9 + 7  N = len(S)  @lru_***(None)  def dp(i, j):  if i == 0:  return 1  elif S[i-1] == '1':  return sum(dp(i-1, k)  for k in range(j, i)) % MOD  else: return sum(dp(i-1, k) for k in range(j)) % MOD  print(sum(dp(N, j) for j in range(N+1)) % MOD)
点赞 回复 分享
发布于 2019-09-08 17:24
请问爱奇艺测开笔试题型都有什么啊?
点赞 回复 分享
发布于 2020-08-21 18:26

相关推荐

头发暂时没有的KFC总裁:找廉价劳动力罢了
点赞 评论 收藏
分享
02-12 00:59
已编辑
哈尔滨工业大学 产品经理
华为 软件开发岗 20.6*16薪 本科
点赞 评论 收藏
分享
评论
1
12
分享

创作者周榜

更多
牛客网
牛客企业服务