RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-298798

Dr. kott9ra's questions

Martin Hope
Dr. kott9ra
Asked: 2020-01-09 22:14:33 +0000 UTC

大规模阵列[关闭]

  • -1
关闭。这个问题需要澄清或补充细节。目前不接受回复。

想改进这个问题?通过编辑此帖子添加更多详细信息并澄清问题。

3年前关闭。

改进问题

有一个 Olympiad 问题,内存限制为 256 MB。我需要创建一个 100000 x 100000 矩阵。当我这样做时,会抛出 OutOfMemoryException。怎么打?UPD:谢谢你的回答,明白了。

java
  • 1 个回答
  • 10 Views
Martin Hope
Dr. kott9ra
Asked: 2020-01-03 03:17:35 +0000 UTC

有趣的奥林匹克问题。[关闭]

  • -1
关闭 这个问题是题外话。目前不接受回复。

寻求调试帮助的问题(“为什么这段代码不起作用? ”)应该包括期望的行为、具体的问题或错误,以及在问题中重现它的最少代码。没有明确描述问题的问题对其他访问者毫无用处。请参阅如何创建一个最小的、独立的和可重现的示例。

3年前关闭。

改进问题

有一个问题,很简单,我想。解决方案马上就来了:我们寻找天数的最大值(d-th),并输出它是星期几。因为要让他们相遇,所有的日子都必须是最长的一天的除数。(我们得到一个天数组,并按降序排序,所有元素都是第一个元素的除数)测试 4 失败。我找不到错误。

格林德沃想要召集他的支持者。但是,不幸的是,他不能每天都这样做。格林德沃总共有 n 个支持者。让我们将它们从 1 编号到 n。第 i 号支持者基于个人信念,每隔 di 天(即如果第 i 号支持者两次访问之间的间隔为 di 天)访问会面地点。格林德沃记得,上一次他的所有支持者同时出现在集会地点是在星期几,编号为 s。帮助他确定一周中的哪一天,所有支持者将再次同时出现在集合地点。回想一下,一周有 7 天,格林德沃按照 1 到 7 的顺序对它们进行编号

下列的。 输入格式 输入 的第一行包含两个整数 n 和 s (1 ⩽ n ⩽ 105 , 1 ⩽ s ⩽ 7)。第二行包含 n 个整数 di (1 ⩽ di ⩽ 20)。输出数据格式 输出1到7的单个数字——星期几

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Created by Andrey on 31.12.2018.
 */
public class Main {
    static int scanInt() throws IOException {
        return parseInt(scanString());
    }



    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static StringTokenizer tok;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        int n = scanInt();
        int s = scanInt();

        ArrayList<Integer> days = new ArrayList<>();

        for(int i = 0; i < n; ++i){
            days.add(scanInt());
        }
        days.sort(Collections.reverseOrder());



        ArrayList<Integer> week = new ArrayList<>();
        for(int i = 0; i < 1000; ++i){
            week.add(1);
            week.add(2);
            week.add(3);
            week.add(4);
            week.add(5);
            week.add(6);
            week.add(7);
        }

        System.out.println(week.get(s+days.get(0) - 1));







    }
}
java
  • 2 个回答
  • 10 Views
Martin Hope
Dr. kott9ra
Asked: 2020-12-31 21:24:24 +0000 UTC

点是否属于线段的问题

  • 2

有一个任务:

第一行包含两个整数 1≤n≤50000 和 1≤m≤50000——分别是线上的线段数和点数。接下来的 n 行包含两个整数 ai 和 bi (ai ≤ bi)——线段末端的坐标。最后一行包含 m 个整数——点的坐标。所有坐标不超过 10^8 模。如果一个点在它内部或在边界上,则它被认为属于一个线段。对于每个点,按照在输入中出现的顺序,输出它属于多少个段。

我想出了一个解决方案:从头开始对段进行排序。此外,我们在点和段上运行。我们看,如果该点属于段,那么我们增加计数器,并注意它至少属于一个段。接下来,我们看,如果该点不属于任何段,但属于至少一个段,那么它也不属于所有后续段。(因为这些段是按初始坐标的升序排列的)。但我对一项测试有疑问:

[6 6]
[2 3]
[2 5]
[3 5]
[2 7]
[5 7]
[3 7]
  • 段,1 2 3 5 6 7 - 点。当答案是 0 3 5 5 3 3 时给出 0 3 5 5 1 1。我想知道我的算法中的错误在哪里。如果是的话,请把我推向正确的解决方案:)

    导入 java.io.BufferedReader;导入 java.io.IOException;导入 java.io.InputStreamReader;导入 java.util.*;

    import static java.lang.Integer.parseInt;
    
    /**
     * Created by Andrey on 31.12.2018.
     */
    public class Stepic {
        static int scanInt() throws IOException {
            return parseInt(scanString());
        }
    
    
    
        static String scanString() throws IOException {
            while (tok == null || !tok.hasMoreTokens()) {
                tok = new StringTokenizer(in.readLine());
            }
            return tok.nextToken();
        }
    
        static BufferedReader in;
        static StringTokenizer tok;
        public static void main(String[] args) throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            int n = scanInt();
            int m = scanInt();
            int[] ans = new int[m];
            List<Segment> segments = new ArrayList<>();
            for(int i = 0 ; i < n; i++){
                segments.add(new Segment(scanInt(),scanInt()));
            }
    
            segments.sort(Comparator.comparingInt(o -> o.x));
    
            int[] dots = new int[m];
            boolean[] dotsB = new boolean[m];
            for(int i = 0; i < m; i++){
                dots[i] = scanInt();
            }
    
            for(int i = 0; i < dots.length; i++){
                for (Segment segment : segments) {
                    if (segment.x <= dots[i] && segment.y >= dots[i]) {
                        ans[i]++;
                        dotsB[i] = true;
                    } else {
                        if (dotsB[i]) {
                            break;
                        }
                    }
                }
            }
    
            for(Segment segment : segments){
                System.out.println(segment.x + " " + segment.y);
            }
    
    
            for (int an : ans) {
                System.out.print(an + " ");
            }
    
        }
    
        public static class Segment{
            public int x;
            public int y;
    
    
            public Segment(int x, int y) {
                this.x = x;
                this.y = y;
            }
        }
    }
    
java
  • 2 个回答
  • 10 Views
Martin Hope
Dr. kott9ra
Asked: 2020-06-04 00:15:41 +0000 UTC

Unity3D:光束投掷方法

  • 0

我正在阅读 Joseph Hawking 的 Unity in Action。我目前在第 3 章,我们正在编写第一人称射击游戏。我不清楚投掷光束的方法是如何实现的(对于投篮的实现,还有几点)。请参阅代码中的注释。请给我解释一下,提前谢谢!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RaySh : MonoBehaviour {

    private Camera camera;

    // Use this for initialization
    void Start () {
        camera = GetComponent<Camera>();
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    void OnGUI(){
        int size = 12; 
        float posX = camera.pixelWidth / 2 - size / 4; //зачем здесь вычитается size / 4
        float posY = camera.pixelHeight / 2 - size / 2; //зачем здесь вычитается size / 2
        GUI.contentColor = Color.black;
        GUI.Label(new Rect(posX, posY, size, size), "*");

    }

    // Update is called once per frame
    void Update () {
        if(Input.GetMouseButtonDown(0)){ // полностью не понятен метод бросания луча (код ниже)
            Vector3 point = new Vector3(camera.pixelWidth / 2, camera.pixelHeight / 2, 0);
            Ray ray = camera.ScreenPointToRay(point);
            RaycastHit hit;
            if(Physics.Raycast(ray, out hit)){
                StartCoroutine(SphereIndicator(hit.point));
            }
        }

    }
    private IEnumerator SphereIndicator(Vector3 pos){   
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.transform.position = pos;
            yield return new WaitForSeconds(1);
            Destroy(sphere);
        }
}
unity3d
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5