网易游戏笔试题代码分享 【3/4】

网易的就不是特别水了
今天网易游戏的直接教做人呀!!!

第四题 字符串计算的 大模拟直接GG。。。

// test1 [100/100]
等腰三角形

#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N  = 300000+10;

int main(){
    int n;
    scanf("%d",&n);
    for(int i=2;i<=n;i++) printf(".");puts("*");
    for(int i=2;i<n;i++){
        for(int j=n-i;j;j--) printf(".");
        printf("*");
        for(int j=i*2-3;j;j--) printf(".");
        puts("*");
    }
    for(int i=1;i<n+n;i++) printf("*");
    puts("");
    return 0;
}

// test2 [100/100]
放小球

#include<bits/stdc++.h>
using namespace std;
int dp[32][32][32][32][11];
int main()
{
    int A,B,C,D,a,b,c,d;
    while(~scanf("%d%d%d%d%d%d%d%d",&A,&B,&C,&D,&a,&b,&c,&d)){
        int ans=0;
        for(int i=0;i<=A;i++)for(int j=0;j<=B;j++)
            for(int k=0;k<=C;k++)for(int l=0;l<=D;l++)
                for(int num=0;num<=9;num++) dp[i][j][k][l][num]=-1000000000;

        dp[0][0][0][0][0]=0;
        for(int i=0;i<=A;i++){
            for(int j=0;j<=B;j++){
                for(int k=0;k<=C;k++){
                    for(int l=0;l<=D;l++){
                        for(int num=0;num<=9;num++){
                            if(i<A) dp[i+1][j][k][l][(num+a)%10]=max(dp[i+1][j][k][l][(num+a)%10],num*a+dp[i][j][k][l][num]);
                            if(j<B) dp[i][j+1][k][l][(num+b)%10]=max(dp[i][j+1][k][l][(num+b)%10],num*b+dp[i][j][k][l][num]);
                            if(k<C) dp[i][j][k+1][l][(num+c)%10]=max(dp[i][j][k+1][l][(num+c)%10],num*c+dp[i][j][k][l][num]);
                            if(l<D) dp[i][j][k][l+1][(num+d)%10]=max(dp[i][j][k][l+1][(num+d)%10],num*d+dp[i][j][k][l][num]);
                            ans=max(ans,dp[i][j][k][l][num]);
                        }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}

// test3 [20/100]
打怪兽

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e,f;
    while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
        int output=0x3f3f3f3f;
        if(e==0)e=10000;
        if(f==0)f=10000;
        for(int i=b;i<=300;i+=e){
            for(int j=d;j>=-100;j-=f){
                int sum=0;
                int aa,bb,cc,dd,ee,ff;
                aa=a;bb=b;
                cc=c;dd=d;
                ee=e;ff=f;
                while(dd>j&&sum<3000){
                    if(aa>(dd-f))dd-=f;
                    else aa=a;
                    sum++;
                    aa-=dd;
                }
                while(bb<i&&sum<3000){
                    if(aa>(dd))bb+=e;
                    else aa=a;
                    sum++;
                    aa-=dd;
                }
                while(cc>0&&sum<3000){
                    if(cc-bb<=0){
                        sum++;
                        break;
                    }
                    if(aa>dd)cc-=bb;
                    else aa=a;
                    sum++;
                    aa-=dd;
                }
                if(sum>=3000)continue;
                if(aa<0)continue;
                output=min(output,sum);
            }
        }
        if(output==0x3f3f3f3f)printf("IMPOSSIBLE\n");
        else printf("%d\n",output);
    }
}

// test4 [6.67/100]

开始写了个只带+的 给了6.67%
最后写全了交 实力爆0。。。。23333
#笔试题目##春招##网易#
全部评论
最后一题过了83%,实在不知道还有什么坑的。。反正直接导致了前两题没时间做了 = = #include <iostream> #include <vector> #include <map> #include <cstring> #include <string> #include <algorithm> using namespace std; string ss; string opst[1005]; int oppos; string allst[1005]; int allpos; int start, len; string numst[1005]; int numpos; map<char, int> opma; bool ischar(char c) { if (c >= 'a' && c <= 'z') return true; if (c >= 'A' && c <= 'Z') return true; if (c >= '0' && c <= '9') return true; return false; } bool isnum(string s) { if (s.length() > 1) return true; if (ischar(s[0])) return true; return false; } string fan(string s) { for (int i = 0; i < s.length(); ++i) { if (s[i] >= 'a' && s[i] <= 'z') { s[i] -= 'a' - 'A'; continue; } if (s[i] >= 'A' && s[i] <= 'Z') { s[i] -= 'A' - 'a'; continue; } } return s; } string fu(string s) { string t(s.rbegin(), s.rend()); return t; } string chen(string s1, string s2) { string rst = ""; rst += s1[0]; for (int i = 1; i < s1.length(); ++i) { rst += s2; rst += s1[i]; } return rst; } string chu(string a, string b) { int flag = 1, m; while(flag) { m = a.find(b); if (m < 0) { flag = false; } else { a.erase(m, b.length()); } } return a; } string jia(string a, string b) { return a + b; } string jian(string a, string b) { int flag = 1, m; m = a.find(b); if (m < 0) { flag = false; } else { a.erase(m, b.length()); } return a; } void solve() { oppos = 0; allpos = 0; start = 0; len = 0; ss = chu(ss, "()"); if (ss[0] == '-') { ss[0] = '='; } for (int i = 1; i < ss.length(); ++i) { if (ss[i] == '-') { if ((!ischar(ss[i-1])) && (ss[i-1]!=')')) { ss[i] = '='; } } } for (int i = 0; i < ss.length(); ++i) { if (ischar(ss[i])) { len ++; continue; } else { if (len != 0) { allst[allpos ++] = ss.substr(start, len); len = 0; } start = i + 1; if (ss[i] == '~' || ss[i] == '=') { opst[oppos ++] = ss.substr(i, 1); continue; } if (ss[i] == '(') { opst[oppos ++] = "("; continue; } if (ss[i] == ')') { while(opst[oppos - 1][0] != '(') { allst[allpos ++] = opst[oppos - 1]; oppos --; } oppos --; continue; } while(oppos > 0 && opma[ss[i]] < opma[opst[oppos - 1][0]]) { allst[allpos ++] = opst[oppos - 1]; oppos --; } opst[oppos ++] = ss.substr(i, 1); } } if (len != 0) { allst[allpos ++] = ss.substr(start, len); } while(oppos > 0) { allst[allpos ++] = opst[oppos - 1]; oppos --; } numpos = 0; for (int i = 0; i < allpos; ++i) { if (isnum(allst[i])) { numst[numpos ++] = allst[i]; continue; } if (allst[i][0] == '~') { numst[numpos - 1] = fan(numst[numpos - 1]); continue; } if (allst[i][0] == '=') { numst[numpos - 1] = fu(numst[numpos - 1]); continue; } if (allst[i][0] == '*') { numst[numpos - 2] = chen(numst[numpos - 2], numst[numpos - 1]); numpos --; continue; } if (allst[i][0] == '/') { numst[numpos - 2] = chu(numst[numpos - 2], numst[numpos - 1]); numpos --; continue; } if (allst[i][0] == '+') { numst[numpos - 2] = jia(numst[numpos - 2], numst[numpos - 1]); numpos --; continue; } if (allst[i][0] == '-') { numst[numpos - 2] = jian(numst[numpos - 2], numst[numpos - 1]); numpos --; continue; } } cout << numst[0] << endl; } int main() { ios::sync_with_stdio(false); //freopen("input.txt", "r", stdin); opma['+'] = 1; opma['-'] = 1; opma['*'] = 2; opma['/'] = 2; opma['~'] = 3; opma['='] = 3; opma['('] = 0; opma[')'] = 0; cin >> ss; solve(); return 0; }
点赞 回复 分享
发布于 2018-03-28 22:00
import java.util.Scanner; public class SanJiao {     public static void main(String[] args) {         // TODO Auto-generated method stub         Scanner sc = new Scanner(System.in);         while (sc.hasNext()) {             int H = sc.nextInt();             solution(H);         }         sc.close();     }     private static void solution(int h) {         // TODO Auto-generated method stub         for (int i = 0; i < h; i++) {             for (int j = 0; j < h-i-1; j++) {                 System.out.print("."+"\t");             }             for (int j = 0; j < i*2+1; j++) {                 if (i<h-1) {                     if (j>0&&j<i*2) {                         System.out.print("."+"\t");                     }else {                         System.out.print("*"+"\t");                     }                 }                 if (i==h-1) {                     System.out.print("*"+ "\t");                 }             }             System.out.println();         }     } }
点赞 回复 分享
发布于 2018-03-28 21:59
还有我想说,楼主你这样设计的dp有一维是多余的,只要四维就够了,我一开始按照你的维,内存爆成狗
点赞 回复 分享
发布于 2018-03-28 21:49
我不会和你们说网易打怪兽出题人抄袭了2017google code jam round1的C题
点赞 回复 分享
发布于 2018-03-28 21:46
数据挖掘只有前两道编程,后面6道问答题_(:з」∠)_
点赞 回复 分享
发布于 2018-03-28 21:38
人工智能平台开发的题画风完全不同。。。
点赞 回复 分享
发布于 2018-03-28 21:35
透心凉 网易游戏届不到
点赞 回复 分享
发布于 2018-03-28 21:35

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务