小编Dee*_*pak的帖子

解决方案适用于样本数据,但在线判断会出错吗?

这是我想解决的问题:

B:狐狸的宝藏

有一个N(N1≤≤4)福克森守着一个宝贵的宝藏,你喜欢亲自动手.问题是,Foxen肯定不会允许 - 至少,不是在他们醒着的时候.

幸运的是,通过仔细观察,你已经看到每个狐狸都有一个规律的睡眠周期.特别是,i狐狸保持清醒 Ai(1≤≤23 Ai)小时,然后睡眠Si(Si1≤≤23)小时,无限期地重复这种模式(Ai + Si2≤≤24).在你的宝藏尝试开始时,i福克斯正好Oi(0≤ Oi< Ai + Si)小时进入它的周期.

如上所述存在T(1≤≤20 T)场景.对于每一个,你想确定所有的狐狸会在多长时间内同时睡着,让你抓住他们的宝藏,或者如果这根本不会发生.

输入

Line 1: 1 integer, T
For each scenario:
    Line 1: 1 integer, N
    Next N lines: 3 integers, Ai, Si, and Oi, for i = 1..N
Run Code Online (Sandbox Code Playgroud)

产量

For each scenario:
    Line 1: 1 integer, the minimum number of hours after the start …
Run Code Online (Sandbox Code Playgroud)

python python-2.7

8
推荐指数
2
解决办法
320
查看次数

Python,PIP,线分析器的失败构建轮

我正在尝试为 ipython 安装线分析器。我正在使用 anaconda 来使用 python。

当前版本的python是:

Python 3.6.2 |Anaconda, Inc.| (default, Sep 19 2017, 08:03:39) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 pip 安装线路分析器时,这是我得到的错误输出。

注意:我正在用 python 运行 anaconda。

C:\Users\dsandhu>pip install line_profiler
Collecting line_profiler
  Using cached https://files.pythonhosted.org/packages/14/fc/ecf4e238bb601ff829068e5a72cd1bd67b0ee0ae379db172eb6a0779c6b6/line_profiler-2.1.2.tar.gz
Requirement already satisfied: IPython>=0.13 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from line_profiler) (6.1.0)
Requirement already satisfied: setuptools>=18.5 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from IPython>=0.13->line_profiler) (36.5.0.post20170921)
Requirement already satisfied: jedi>=0.10 in c:\program …
Run Code Online (Sandbox Code Playgroud)

python pip anaconda

6
推荐指数
2
解决办法
5349
查看次数

clang没有编译c程序?

在c中编程时,我使用clang编译大部分时间.突然它停止了工作.每当我尝试编译某些内容时,它都会给我输出这个输出假设文件名是test.c

clang test.c 

In file included from test.c:1:
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
          ^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

test.c的来源是:

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
  printf("\nthis is a sample c program\n");
  return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

注意:在像gcc这样的其他编译器上它仍然有效.我应该怎么做让clang回来工作?

如果您需要有关系统的任何信息:我使用的是32位Ubuntu 13.10.文本编辑器:Emacs.

我也试图卸载clang然后重新安装仍然得到相同的错误.


我在"usr/include/linux"中找到了该文件,然后将其粘贴到"usr/include"中,它现在向我显示同一文件的错误但要求另一个

In file included from test.c:1:
In file included from /usr/include/stdio.h:74:
/usr/include/libio.h:50:10: fatal error: 'stdarg.h' file not found
#include <stdarg.h>
     ^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

现在我试图搜索新文件""并在不同的文件夹中找到多个具有相同名称的文件,这使得它令人困惑,这是我需要在clang目录中复制粘贴的正确文件.

有没有其他方法可以解决头文件的问题?


现在我找到了clang的config.h文件.负责包含文件的两个变量在文件中如下,其当前值如下:

/* Relative directory for resource …
Run Code Online (Sandbox Code Playgroud)

c clang header-files llvm-clang

5
推荐指数
1
解决办法
7441
查看次数

将指针传递给结构作为参数的优势?

我们的编码风格是当我们修改结构的内容时,我们将指向结构的指针传递给函数.

但是,当我们不修改结构的内容时,是否还有理由更喜欢将指针传递给函数?

c pointers

5
推荐指数
1
解决办法
1160
查看次数

Emacs喜欢崇高文本3中的线路导航?

我过去几个月一直在使用Emacs,我喜欢它的线路导航功能,因为它不需要你使用箭头键.

Emacs线路导航:

C-p : go to previous line
C-n : go to next line
C-f : go forward one character
C-b : go backward one character
Run Code Online (Sandbox Code Playgroud)

无论如何我可以在崇高文本3中使用它吗?我在一些博客中读到有些人这样做但我找不到如何做的说明.

ide emacs text-editor emacs23 sublimetext2

4
推荐指数
1
解决办法
4740
查看次数

任何人都可以帮我理解这个程序中的typedef吗?

它只是一个简单的C程序,我不明白这一点是:当我们写的时候

typedef int RowArray[COLS];    
Run Code Online (Sandbox Code Playgroud)

我认为typedef工作的方式是从typedef直到最后一个单词被";"之前的最后一个单词替换的所有内容.所以在这里必须有类似typedef int RowArray [COLS] X; 那么X*rptr;

但在这里我无法理解.如果可能的话,你可以给我发一个关于typedef的一些材料的链接,在这种情况下解释这种情况.

#include <stdio.h>
#include <stdlib.h>
#define COLS 5

typedef int RowArray[COLS];  // use of typedef 
RowArray *rptr;              // here dont we have to do RowArray[COLS] *rptr;

int main()
{
  int nrows = 10;
  int row, col;
  rptr = malloc(nrows * COLS * sizeof(int));

  for(row=0; row < nrows; row++)
    {
      for(col=0; col < COLS; col++)
    {
      rptr[row][col] = 17;
    }
    }

  for(row=0; row<nrows; row++)
    {
      for(col=0; col<COLS; col++)
    {
      printf("%d  ", …
Run Code Online (Sandbox Code Playgroud)

c typedef

4
推荐指数
1
解决办法
240
查看次数

debian 8:找不到deb命令。我该如何解决?

我正在尝试在台式机上安装显卡Nvidia Geforce 660。操作系统:Debian 8。

这是提供指导的Wiki:https : //wiki.debian.org/NvidiaGraphicsDrivers#jessie-304xx

但是,一旦我迈出第一步:

deb http://http.debian.net/debian/ jessie main contrib non-free

bash: deb: command not found
Run Code Online (Sandbox Code Playgroud)

如何安装deb?

linux debian deb

3
推荐指数
1
解决办法
2万
查看次数

C语言中main方法中参数的目的是什么?

我正在学习C并注意到,如果对于简单的程序(比如打印某些东西或其他简单的东西),即使我删除了主程序中的参数,它仍然可以工作,但是我所关注的书将这些参数放在每个程序中.

#include <stdio.h>

int main(int argc, char const *argv[])
// even works if i do int main() 
{
/* write your code here */

return 0;
}
Run Code Online (Sandbox Code Playgroud)

我想了解这些论点的原因,为什么我们把它们和它们用于什么?也许指出一个程序的例子,如果我们从main函数中删除这些参数并指出它们的目的是什么,程序将无法工作?

c arguments

2
推荐指数
1
解决办法
2285
查看次数

在java中正确声明浮动和长类型?

所以我明白,如果我声明一个长变量,我需要在数字的末尾添加一个 L。

long x = 123L;
Run Code Online (Sandbox Code Playgroud)

与 float 类型相同,我需要在变量末尾添加 F。

float x = 1.1F;
Run Code Online (Sandbox Code Playgroud)

但我想知道为什么在这两种情况下它的做法不同?我的意思是如果我声明一个 int 或任何其他数据类型,它就完成了

int x = 1;
Run Code Online (Sandbox Code Playgroud)

为什么这两种数据类型的声明是以某种方式完成的(对于 long 和 float 类型)。我知道它是这样做的,我只是想了解为什么要这样做?

java floating-point double

2
推荐指数
1
解决办法
2519
查看次数

启动原子文本编辑器linux!#.找不到GLIBC_2.14和GLIBC_2.15?

我正在使用crunnchbang linux 64位.我安装了原子文本编辑器,但是当我尝试启动它时它给出了错误.输出如下:

shunya@crunchbang:~$ atom 
shunya@crunchbang:~$ /usr/share/atom/atom: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /usr/share/atom/atom)
/usr/share/atom/atom: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /usr/share/atom/libchromiumcontent.so)
/usr/share/atom/atom: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /usr/share/atom/libgcrypt.so.11)
/usr/share/atom/atom: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.15' not found (required by /usr/share/atom/libgcrypt.so.11)
Run Code Online (Sandbox Code Playgroud)

从输出中可以清楚地看到它需要一些名为GLIBC_2.5和2.14的软件包.我该如何安装这些要求?我试图搜索突触包管理器,如果我搜索GLIBC有很长的包列表.我无法分辨要安装哪一个.

但是一旦我做了GLIBC_2.14或-2.14,就没有剩下的选择了.

*更新:尝试

sudo apt-get install libc6 
Run Code Online (Sandbox Code Playgroud)

我得到输出,因为libc6已经是最新版本了.

debian dependencies glibc libc atom-editor

2
推荐指数
1
解决办法
1万
查看次数

如何使用函数作为参数并应用于lisp中的子列表?

问题很简短.

假设F是任何函数,在这种情况下我使用F= length,并且L是包含子列表的任何列表,例如L在这种情况下是((3 3 3) (2 2) (1)).如何将功能F应用于列表车L

(defun try (F L)
    ('F (car L)))
Run Code Online (Sandbox Code Playgroud)

当我把这个函数称为

(try 'length '((3 3 3) (2 2) (1) (1) ))
Run Code Online (Sandbox Code Playgroud)

我应该得到3的,因为第一Ssblist长度的结果L,(3 3 3)是3.

lisp clisp common-lisp

1
推荐指数
1
解决办法
124
查看次数

如何通过将正确的指针传递给 free() 来释放函数内分配的内存

在函数“create_memory_pool”中,我可以分配内存池,但我不确定如何从主程序中释放它。

我想我缺少如何将正确的指针从函数传递到 free,通过它我可以释放之前分配的内存。

注意我无法更改传递给函数创建内存池的参数(不允许)。但可以改变函数内部的内容。

#include <stdio.h>
#include <stdlib.h>

typedef enum {
   false,
   true
} boolean;

boolean create_memory_pool(char *name, int size)
{
  name = malloc(size);
  if (name != NULL)
    {
      printf("malloc successful\n");
      return true;
    }
  else
    {
      printf("malloc failed\n");
      return false;
    }
}

int main()
{
  boolean rc;
  char *name;


  // case 2
  rc = create_memory_pool(name, 1024);
  free(name);

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c memory-management

0
推荐指数
1
解决办法
497
查看次数

c中的自定义"strcpy"函数

此方法可以将内容从1个字符串复制到另一个.我的问题是当它到达字符串末尾时它是如何停止的?怎么知道什么时候停止?

void strcpy2(char *s, char *t)
{
  while (*s++ = *t++)
    ;
}
Run Code Online (Sandbox Code Playgroud)

c

-1
推荐指数
1
解决办法
880
查看次数