acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 资讯
  • 竞赛
  • 讨论
  • 团队
  • 商城
登录
注册
题目详情提交记录(0)
  • 题解(c++)

    思路:由于题面并没有给出数列(数组)的具体长度,所以用while进行输入。这里可以注意到输入时x和y也会被输入到数组里。所以我们将x和y从数组中取出(注意边界,要从i-1和i-2取),然后直接输出即可。 代码: 时间复杂度:O(n)O(n)O(n)其中n为数列的长度(不含x,y)由于是大O表示法,输入x,y到数组里的可以忽略。

    userId_undefined
    滚木
    出道萌新时间刺客空间掌握者时空双修者枚举·枚举小能手模拟·模拟练习生
    104阅读
    0回复
    3点赞
  • 给我点个赞吧球球了

    本人急刷题解仙人。点个赞吧呜呜呜呜,球球了

    userId_undefined
    不会c++的c++
    题解仙人7月全勤卷王8月全勤卷王
    21阅读
    0回复
    0点赞
  • 代码放这了 你们直接抄就行

    #include <unistd.h> static char inBuf[1 << 10]; static int inLen = 0, inPos = 0; inline int readChar() { if (inPos == inLen) { inLen = read(0, inBuf, sizeof(inBuf)); inPos = 0; if (inLen <= 0) return -1; } return inBuf[inPos++]; } inline int readInt() { int c = readChar(); while (c <= ' ') { if (c == -1) return -1; c = readChar(); } int x = 0; while (c > ' ') { x = x * 10 + (c - '0'); c = readChar(); } return x; } int main() { int a[105]; int n = 0; int v; while ((v = readInt()) != -1) { a[n++] = v; } int y = a[--n]; int x = a[--n]; int ans = a[x - 1] + a[y - 1]; }

    userId_undefined
    Liu(互关)
    出道萌新时空双修者秩序白银快乐小狗
    6阅读
    0回复
    1点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页